Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TCP keepalives sent too early and terminates connection

843790Aug 3 2010 — edited Aug 7 2010
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).

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 4 2010
Added on Aug 3 2010
14 comments
1,403 views