Problems resolving network stability issues

I have an application that creates a network based on user activity. The usual payload sent by the application is 100-200 bytes, so basically there are no heavy lifting tasks. These tasks usually work without any problems (statistically 99.9% or requests are fine), but in addition to these network actions, my application also sends heartbeat back to our servers (which are located on Amazon EC2 (us-east1-d, if it has the meaning)). Heartbeat is sent every 10 seconds as a regular POST request over HTTPS - and this is what actually does not work for me, because the failure rate is much higher than what is observed during normal network activity. During my last 7-hour test, 25% of heart rhythm requests failed (but I saw even 35% of the drops), and it usually holds at that speed. When I disable SSL, the error rate remains on my test device at 8%. This would probably not be a big problem if these failures fell into any pattern (i.e., every fourth, etc., which could mean some filtering based on speed, or fail close to every hour or day , which could mean that the request cap is set somewhere). But nothing like this happens - sometimes a 10-15 request can fail in a row, and this is bad for a heartbeat. In addition, to make things worse, at the moment I see unsuccessful requests, I can connect to the server from the same device, and this works without problems). This issue occurs in any supported version of Android (2.2+).

I use the recent httpclientandroidlib to execute HTTP requests, so I started to suspect that lib was the culprit, so I switched to Android Asynchronous HTTP Client , but that did not give any changes. Basically I get exceptions:

NoHttpResponseException: The destination server was unable to respond. destination server failed to respond to URL: https: //xx.xx.xx.xx/heartbeat/

and for SSL enabled connections:

javax.net.ssl.SSLException: Read error: ssl = 0x784bc588: input / output error during a system call, connection reset by peer Read error: ssl = 0x784bc588: input / output error during a system call, connection reset from user URL: https: //xx.xx.xx.xx/heartbeat/

Basically, I would like to first trace the culprit, so knowing that the application works mainly on mobile networks, I am open to any suggestion on how to continue working with this problem, as I am stuck at the moment.

+6
source share
2 answers

Launch this application and just do regular ping to see the error rate: https://play.google.com/store/apps/details?id=com.ulfdittmer.android.ping

Launch it both in a mobile network (cellular) and in WiFi.

If you use Wi-Fi, run ping -n 100 google.com from your laptop to make sure that your router and network access point are not peeling. If so, unplug the router and plug it back in. Linksys routers and Belkin access points and access points are becoming equally vulnerable.

If you need a 10 second heartbeat, set the HTTP timeout to 3-5 seconds and work quickly and try again if it doesn't work.

0
source

Well, if you share your HttpClient instance through the hearthbeat stream and ui thread, a normal HTTP connection request may cancel the one that was reached. Make sure they do not send the request at the same time, either by locking the object, or to separate instances of HttpClient.

0
source

Source: https://habr.com/ru/post/956633/


All Articles