Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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).

share|improve this answer
    
+1 for beating me to it. One thing I'm not sure on, though: If the application is sending data and the TCP layer isn't getting any ACKs back, is it purely the application's responsibility to handle this condition or should the kernel's TCP stack intervene? –  SmallClanger Apr 19 '12 at 8:54
    
@SmallClanger, TCP has built-in timers and re-transmit is such one of them. –  poige Apr 19 '12 at 9:49
    
This led me in the right direction. I found out that Drizzle connector doesn't support tcp keep alive but that MySQL connector/J does. –  Andreas Wederbrand Apr 19 '12 at 17:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.