I've got an ASP.NET MVC 5 application running with some WebAPI controllers. I have an Android app that sends a request to the WebAPI every second. The strange thing is that it works fine on some phones; the request is sent successfully and the correct function is called. However, on my phone it doesn't work properly; the function is called every 10 to 20 seconds. Then, when I kill the Android app, all the requests suddenly come through and the function is called.
How can this be fixed? Is it perhaps some strange setting on my phone that I must change? I really need the requests to go through every second and get processed.
Using LogCat in Eclipse, I see that an exception is sometimes thrown: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.7:55555 refused.
Thanks for any help.
Update:
After some investigating, it appears that the issue is caused by using AsyncTask. I've found something here which has kind of fixed the problem. However, now a batch of requests is sent every few seconds, instead of once every second. I'll try to implement the request-sending without using AsyncTask.
Related
I am deploying my Nodejs sample app to Google App Engine Flexible env and when I am using google app engine URL which is in the form appspot.com to hit my API, it is taking around 11 secs to send response from my mobile data, but other APIs are sending response in milisecs.
Also, the time delay is only happening when I am opening my android app and sending request to the server after that all requests are taking normal time, and again delay is coming when I again open the app and send request to the server.
Edit - I found that
This can be a caused when your application is still booting up or warming up instances to serve the request and can be called as loading latency. To avoid such scenarios you can implement health check handler like readiness check so that your application will only receive traffic when its ready
That's why I checked in my Logs that readiness check is performed sometimes around 1 sec
and sometimes around 200 ms
Can anyone please tell me is there anything wrong in warming up my instances because I don't think cold boot time is causing this problem.
Edit 2
I have also tried to set min_num_instances: 2 so that once loaded atleast my 2 instances will again not get boot up, but the thing is delay is again same.
Edit 3
runtime: nodejs
#vm: true
env: flex
automatic_scaling:
min_num_instances: 2
max_num_instances: 3
Edit 4
I am noticing a strange behaviour that when I am using this app Packet Capture to capture traffic, then all https requests (if I am not enabling SSL Proxying) and all Http requests are executing in milisecs whereas without using this app all Http/Https requests are taking 11-16 secs of delay.
I don't know how but is there any certificate kind of issue here?
Edit 5
Below I have attached Network Profiler where delay is coming 15 secs
Please Help
Depends on which App Engine you are using and how you setup the scaling, there's always a loading time if you don't have a ready instance to serve a request. But if you have readiness check to ensure your instance is ready (and not cold started for the request), then there shouldn't be a problem.
Can you find a loading request or any corresponding slow request in your logs? If not, then it's likely an issue with the app. If possible, instead of calling this API on your app, do it from two apps (one is already open, one is not). So you make calls from both apps and if you notice that the one that's already open is getting a response faster than the other one, that means that's a problem with the app itself. App Engine can't determine whether or not your app is pre-opened so any difference would be client side.
=== Additional information ===
In the your logs, there's no delay at all. The request enter Google and was processed within a few milliseconds. I am sure there's something application-side. Maybe your app is constructing the request URL (first request) from some other source that results in the delay? App Engine has no knowledge of whether or not your app is opened or not or whether it's sending a first request after being opened, it cannot act differently based on it. As long as your App Engine instance is ready and available, it will treat your request the same way regardless of whether or not it's your first request after the app is opened.
The issue is resolved now, it was happening because of network service provider which is Bharti Airtel, their DNS lookup was taking the time to resolve the hostname. After explicitly using alternative DNS like Google 8.8.8.8 the issue got completely resolved. Maybe it's a compatibility issue of Airtel with Google Cloud.
Last time I checked I remember having to put a warmup request handler so that Google would know that the instance is up and running and can be used to answer calls. Keep in mind that code has to be EXACTLY under the endpoint you specify in the handler under the yaml file. (Wouldn't be the first time someone forgets that)
Here are the docs https://cloud.google.com/appengine/docs/standard/python/configuring-warmup-requests this is python specific, but you can also check other languages like Go, Java, and such in the docs.
If the problem is client dependant (each time a new clients spawns and makes a call it gets the latency) then it is most likely, either a problem with the client app itself or with initialization, registration or DNS resolution.
You could also try to reproduce the requests with CURL or similar, and see if also with those you see the mentioned delay.
In espresso I call a login method on my app from a login button.
The background asynctask does the login which is successful 200 (it gets a token and should save it). A second server call immediately after is made to get user data - performed from the same asynctask (still on the background thread). Then the response is returned to the app for it to continue.
The second call always comes back:
HTTP code 401
getResponse {"Error":{"Code":401,"Message":"Request requires authorization"}}
Because the token is not seen from the first call when running in espresso but this always runs fine with actual user devices for a few years now.
Any ideas how to make it work with espresso?
I think there should be nothing to do as the 2 calls happen on the background thread away from the UI of the app, and there's only one response callback made at the end of the asynctask...
thanks
I used the record espresso function in Studio to do the same thing, and it works fine now.
The code it generates is filled with Thread.sleeps and more excessive code to find a button or edit box, so is a bit ugly but it works correctly and I can do various tests of the app.
I am developing an app which sends the GET request to a server.
Data is going safely to the server but after 5 seconds the app activity stopped unfortunately every time . I am using volley as networking library and running it in genymotion emulator. The server a returns a string value 0 or 1 or 2 depending on the operations.
You are probably making a network call on the main (or UI) thread, your request takes more than 5 seconds and it causes ANR.
I am trying to log my user in with a simple Login with Facebook button with Parse Android SDK 1.9.1 using ParseFacebookUtils.logInWithReadPermissionsInBackground but it takes about more than 10 seconds for the callback to fire. I have many other requests too, including downloading/uploading files, Graph requests etc after the callback returns, all of which take much less than that single login call, so it's not a connection issue. I've tried it multiple times.
Why can this happen?
It was related to something else, and in fact it wasn't caused by the API call.
I have having problems with a WSDL/SOAP service call in an app I have built in flash builder for mobile. I have connected to the service using flash builders built in data/services functionality.
For the most part, the service call works perfectly but once in a while it will cause the app to crash - on my android device it completely locks up (spinning animation stops) and then Android informs me that the app is not responding and asks if I want to close it.
The crash appears to occur quite frequently but not with any pattern. One time it happened on my third attempt, another time it took approximately 30, a couple of times I could not get it to happen and most times it occurs somewhere in between.
It appears that the crash happens after a service call is made but before any response is received. Neither the success or the fault listeners are ever fired. I am very confident that I am sending exactly the same variables to the service every time.
I have used web service calls in other apps without trouble so I have to assume there is something in this particular build that is causing problems but I can't seem to find anything.
Any thoughts on possible causes, things to test or even a solution would be hugely appreciated.
Thank you,
Jamie
Your question lacks essential details, so now I can suggest you to setup Charles proxy and monitor you requests trough it.
If you send too many requests simultaneously, you shall not be confident in fault/result events as air runtime has limitations (in any case, it is a good practice to handle request timeout).