0

I have set tcp_time_wait_interval as 1000 (1 sec). But even after closing the connection, TCP TIME_WAIT state are accumulating. Can anyone please help me on this.

var net = require('net');
var HOST = 'localhost';
var PORT = 9790; 
net.createServer(function(sock) {
    sock.on('data', function(data) {
        console.log('Application Name : ' + data);     
        sock.write('Connected to "' + data + '"');
    });
    sock.on('close', function(data) {
        console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
    });    
}).listen(PORT, HOST);
console.log('Server listening on ' + HOST +':'+ PORT);

In LINUX sysems it's working fine. TIME_WAIT is not accumulating. So I hope there is nothing wrong with the code.

user207421
  • 305,947
  • 44
  • 307
  • 483
madz
  • 168
  • 2
  • 11
  • I would say that you clearly *haven't* set `tcp_time_wait_interval` as one second. In any case that is two orders of magnitude too short. – user207421 Jul 25 '16 at 10:00
  • By default the value is 60 Sec. But in 10 mins many TIME_WAIT connections getting accumulated. – madz Jul 25 '16 at 10:10
  • You need to lookup what it's for, and discover *why* one scond is too short. If you really think you have a problem, which isn't proven, the answer lies in having the peer close the connection first, not in fiddling with TCP parameters you don't really understand. – user207421 Jul 25 '16 at 10:23
  • Sorry if I am wrong, But only if the connection is properly closed the connection goes into TIME_WAIT state right? – madz Jul 25 '16 at 10:57
  • When you close it, the client can still have data for you. What are ypur clients foing? Does http://www.sean.de/Solaris/soltune.html#tcp_time_wait_interval help? – Walter A Aug 03 '16 at 22:02
  • Another source, https://www.veritas.com/support/en_US/article.000090375, states that 1 sec is to short: A value of 60 seconds is considered safe by virtually all vendors. Lower values may cause retransmitted packets to be received after a port is reused. This may result in data from one application being presented to a different application, which will likely lead to an application fault and perhaps a breach of data security. (..) determine why so many sockets are being created so fast and address the implementation that leads to the condition. – Walter A Aug 03 '16 at 22:09

1 Answers1

0

The problem is the connection is closed at server side. When its closed at client side after completing the request. The problem didnt exist. Thanks for the support guys.

madz
  • 168
  • 2
  • 11