Android random exceptions on HTTP calls. Why?

2019-07-22 17:39发布

I'm testing my app on 3 devices so far. One device LG Optimus from Sprint never throws exceptions on https calls (maybe once in a week)

Nexus S on T-Mobile almost every hour come up with something like this:

Read error: ssl=0x3f4060: I/O error during system call, Connection reset by peer

Now I got tablet for testing (S7 slim) and it's connected via WiFi and I get errors like:

SSL shutdown failed: I/O error during system call, Broken pipe

Do you know why those happen and is there any way to avoid them?

标签: android http
1条回答
太酷不给撩
2楼-- · 2019-07-22 18:14

Rest by peer means the server is rejecting/losing your connection. The SSL failure is probably a direct result of the connection reset. My bet is that this happen when switching networks (wifi to 3G) in the middle of some long standing connection.

If possible create a connection, do any IO, and disconnect as quickly as possible. If you do need to handle long persistent connection be prepared to handle such exceptions and reconnect behind the scenes.

查看更多
登录 后发表回答