Reputation: 3454
I have a Java network server running online on a dedicated server, and I have an Android network client written with Android SDK and java.
It's working fine if the android device is connected with WIFI, but if I connect the device using 3G, the socket is closed when I call: readInt()
from the client. It's not happening at the first call, but later. It looks very random, and it's hard to explain, but it may happen when there is no data too read any more (or not). The exception is SocketException connection reset by peer
.
I would like to explain more specifically, but it is very hard to debug, and to my point of view, it looks like an Android bug (not sure about that). And that's why i'm asking this question. Because for sure someone has encountered the same problem.
What could be the difference between a WIFI connection and a 3G connection for an android device, that would produce such a disconnection ? What could possibly be a fix for this ?
Thanks if anyone can help.
Edit: My 3G connection is NOT breaking. It's the socket that is beaking, and only the socket. And it only happens if I connect in 3G. Not in WIFI.
Upvotes: 0
Views: 1451
Reputation: 3454
I found the answer: Several 3G network providers close their customers' sockets in order to make more profit. The only solution is to artificially slow down the traffic.
Upvotes: 0
Reputation: 3928
Your connection might be breaking in between, in that case the socket you created before is corrupted/closed. I would suggest you to listen for Network change intent "android.net.conn.CONNECTIVITY_CHANGE" and reset your socket everytime there is a change in network.This should fix your issue
Upvotes: 1