Image may be NSFW.
Clik here to view.
I’m experimenting with lost connections between my java application and my mysql server.
The application and the server are on two different machines and I’m pulling the physical cord between the two.
I’m running netstat -plunta
to find out the state of the connection and here is the weird part. I can see the connection in state ESTABLISHED for a very long time after I pull the cord. At least a couple of hours. Is that supposed to be so? When will a connection terminate when no packets can get through?
Both machines are running Linux/Ubuntu. One is 10.04 and one is 11.04.
Image may be NSFW.
Clik here to view.
Well, as I’ve already said in my previous attempt to answer your question, the keyword for soultion is “keep-alive“. TCP connection can be in idle state (no data flowing) literally forever. Sometimes it’s useful and sometimes it’s not. So, 2 approaches: application implements some probing traffic periodically or uses TCP’s “extension” keep-alive (TCP_KEEPALIVE).
Check more discussion of this question.