简体   繁体   中英

TCP socket state become persist after changing IP address even configured keep-alive early

I met a problem about TCP socket keepalive.

TCP keep-alive is enabled and configured after the socket connection, and system has its own TCP keep-alive configuration.

'ss -to' can show the keep-alive information of the connection.

The network interface is a PPPOE device, if we ifup the interface, it will get a new ip address. And the old TCP connection will keep establish until keep-alive timeout.

But sometimes 'ss -to' shows that the tcp connection becomes 'persist', which will take long time (about 15 minutes) to close.

Following is the result of 'ss -to':

ESTAB   0        591           172.0.0.60:46402        10.184.20.2:4335     timer:(persist,1min26sec,14)

The source address is '172.0.0.60', but the network interface's actual address has been updated to '172.0.0.62'.

This is the correct result of 'ss -to':

ESTAB  0        0             172.0.0.62:46120       10.184.20.2:4335    timer:(keepalive,4.480ms,0)

I don't know why the "timer" is changed to 'persist', which makes keep-alive be disable.

In short: TCP keepalive is only relevant if the connection is idle, ie no data to send. If instead there are still data to send but sending is currently impossible due to missing ACK or a window of 0 then other timeouts are relevant. This is likely the problem in your case.

For the deeper details see The Cloudflare Blog: When TCP sockets refuse to die .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM