Home > other >  TCP connection, a display, a display has been disconnected
TCP connection, a display, a display has been disconnected

Time:10-05

Phenomenon: a TCP connection between two machines, a display has been disconnected, a display established
Because the code is not involved, to the operation of the TCP connection level at that time no screening,
Consult about the possible causes and solutions,

Existing HAproxy server, and nodejs (socket. IO) server
Users to establish connection with nodejs need: browser - & gt; Ali SLB - & gt; HA - & gt; NodeJS
Recently found that when no users use NodeJS machine still has a number of connections from HA (netstat command to see)
On the HA machines, however, can't see these connections,
================
Such as: in a NodeJS (13.8) on the machine performs
 [13.8] $netstat - NAT | grep 10711 
TCP 0 0 192.168.13.8:3007, 10711:192.168.13.13 ESTABLISHED

This output shows that 13.8 and 13.13 10711 set up a connection

However, the execution result on HA (13.13) is
 [13.13] $netstat - NAT | grep 10711 
[13.13] $

Without the connection information
================

This connection will disappear, now have not found due to the constantly accumulated, so by now restart NodeJS service solution, after the restart NodeJS service (don't have to restart the machine, just NodeJS process), the connection will disappear,

CodePudding user response:

Netstat anop, parameters o can view the TCP keepalive timer state, preliminary suspect you accumulate on the server of a TCP connection is the timer off state, this state is no keepalive detection, the timer is closed, never trigger expired, the code can be used in the setsockopt setting SO_KEEPALIVE to manually open,

CodePudding user response:

reference 1st floor Runnerchin response:
netstat anop, parameters o can view the TCP keepalive timer state, preliminary suspect you accumulate on the server of a TCP connection is the timer off state, this state is no keepalive detection, the timer is closed, never trigger expired, the code can be used in the setsockopt setting SO_KEEPALIVE to manually open,


Looked really is off,
I look normal connection in the established state are off ah, don't see why this part why he would not disappear,
Project is based on the nodejs, I has no experience in this aspect, but in making the search nodejs source code, is what you have said setting SO_KEEPALIVE,

User side and normal closed HAproxy in front of the machine and has been established and nodejs,
Online appear constantly,,, haven't been able to repetition, test environment, and sorrow,,,

CodePudding user response:

It's not clear,
Timer off the connection can be recycled when normally closed off, the closing of the anomaly it found no, so would accumulate, specific to pick the create the connection code why this timer is not open,

CodePudding user response:

After various caught, found the problem,
Ali cloud network packet loss, RST packet lost, nodejs as Runnerchin said, because the timer off is no longer change
  • Related