koush / ion

Android Asynchronous Networking and Image Loading
Other
6.3k stars 1.04k forks source link

Connection reset by peer Exception #777

Open cvaught opened 7 years ago

cvaught commented 7 years ago

I have an Android application where I use Ion for some of the connectivity. The connections are exclusively via SSL and to a web service that I control. The first thing a user does that results in network activity is login and I use Ion for this. This works as expected except for one specific user that has limited all internet access on the Android device to only work with my web service. They have done this by using their router to create a firewall that blocks all traffic except the specified domains. When this firewall is turned on they can't login via the app because of the following error:

 java.net.SocketException recvfrom failed: ECONNRESET (Connection reset by peer)

They can use the browser to go to my website and access the same web service with the firewall turned on and everything works fine. In addition, they can turn the firewall off, login successfully, turn it back on and everything continues to work. They can even log off and log back in and everything continues to work. It continues to work with the filter on until they quit the app. When they then restart the app and try to login the error returns. This seems like very odd behavior and I'm not entirely sure it is an ion issue but I'm not sure what to do. The full stack trace is shown below.

java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:545) at libcore.io.IoBridge.recvfrom(IoBridge.java:521) at java.nio.SocketChannelImpl.readImpl(SocketChannelImpl.java:327) at java.nio.SocketChannelImpl.read(SocketChannelImpl.java:289) at com.koushikdutta.async.SocketChannelWrapper.read(SocketChannelWrapper.java:24) at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:134) at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:820) at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:657) at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:44) at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:599) Caused by libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer) at libcore.io.Posix.recvfromBytes(Posix.java) at libcore.io.Posix.recvfrom(Posix.java:136) at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:159) at libcore.io.IoBridge.recvfrom(IoBridge.java:518) at java.nio.SocketChannelImpl.readImpl(SocketChannelImpl.java:327) at java.nio.SocketChannelImpl.read(SocketChannelImpl.java:289) at com.koushikdutta.async.SocketChannelWrapper.read(SocketChannelWrapper.java:24) at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:134) at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:820) at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:657) at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:44) at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:599)

cvaught commented 7 years ago

I have switched the initial login to use Volley instead of Ion and the user now reports that they can login with the firewall turned on. I would prefer to stick with Ion. Any reason why Ion would cause this behavior but not Volley?

koush commented 7 years ago

Is it the Android device running the firewall, or something external? Any way I can repro this?

cvaught commented 7 years ago

The user is running the firewall on their router. I tried reproducing it by running a firewall on my devices and it didn't cause the issue. My router doesn't support white list domains, only black listing specific sites. Thus, I haven't been able to reproduce the issue myself. My assumption is that you should be able to reproduce it if you have a router that supports white listing specific domains