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.