views:

55

answers:

0

I'm trying to implement an persistent TCP connection between an Android phone and a desktop server.

I've got heartbeat threads on both ends which are sending keepalive-packets on application level successfully.

The problem is that after a while (varies between 5-20min) the phone is starting to send TCP keepalives to the server, which the server does not seem to respond to. (I'm using Wireshark to monitor this).

This results in an exception on the server thread which is reading from the phone:java.net.SocketException: Connection reset

Why are the phone sending TCP keepalives so early? Even when there's constantly activity on application level? And why doesn't the desktop server respond to this keepalives?

I've checked my Android phone's settings with "sysctl -A | grep net.ipv4" and "net.ipv4.tcp_keepalive_time" is set to 7200 (2 hours).