I establish a TCP connection between Android app and a web server. If I don’t send any packets in one hour, then I can’t use this connection to send/receive data any more. Do I have to send some heartbeat packets? What’s the timeout value for a TCP connection in Android if I don’t send any data over this connection?
The Android version is 2.2. I use HTTP long polling to access a server.
Assuming you’re actually just making an HTTP request, I would strongly suggest that you don’t try to keep it alive indefinitely. Even if both your client code and the server is happy to do so, you may well find there are various proxies in the way which may want to terminate the connection before that. (Admittedly I’d expect the client side to then see the request fail.)
From what I remember of the last time I looked into long polling, around 8 minutes is a reasonable timeout for a long polling request. You’d still only be making eight requests an hour, so it’s not like there’d be a huge amount of traffic – and I strongly suspect it would be a lot more reliable.