NodeJS socket problem FIN_WAIT1 FIN_WAIT2 CLOSE_WAIT

We were facing some problems with NodeJs when handling sockets and file descriptors.

Fortunately we applied this patch and the problem is gone

https://github.com/soplwang/node-ka-patch

/* Copyright (c) 2013 Wang Wenlin. See LICENSE for more information */
;(function () {
var TCP = process.binding('tcp_wrap').TCP
, _setKeepAlive = TCP.prototype.setKeepAlive
, _shutdown = TCP.prototype.shutdown;
TCP.prototype.setKeepAlive = function (enable) {
var r = _setKeepAlive.apply(this, arguments);
this._ka = enable;
return r;
};
TCP.prototype.shutdown = function () {
var r = _shutdown.apply(this, arguments);
if (r && !this._ka)
_setKeepAlive.call(this, true, 150); // 150 sec
return r;
};
})();

And this patch

https://github.com/kejyun/socket.io/commit/8d6c02a477d365f019530b4ec992420dfb90eb09

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: