node-dns icon indicating copy to clipboard operation
node-dns copied to clipboard

Please add this._socket.on('error') in TCPSocket.prototype.bind

Open kupson opened this issue 10 years ago • 2 comments

Hi,

Please consider adding error listener/emitter on TCP sockets. Right now I'm getting errors like below:

2015-06-30_16:14:17.57533 events.js:85
2015-06-30_16:14:17.57541       throw er; // Unhandled 'error' event
2015-06-30_16:14:17.57542             ^
2015-06-30_16:14:17.57544 Error: connect ETIMEDOUT
2015-06-30_16:14:17.57545     at exports._errnoException (util.js:746:11)
2015-06-30_16:14:17.57546     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)

As a quick workaround I monkey-patched TCPSocket:

var native_dns_utils = require('native-dns/lib/utils');
native_dns_utils.TCPSocket.prototype._monkey_catchMessages = native_dns_utils.TCPSocket.prototype.catchMessages;
native_dns_utils.TCPSocket.prototype.catchMessages = function () {
    var self = this;
    this._socket.on('error', function(err) {
        self.bound = false;
        self.emit('close', err);
    });
    this._monkey_catchMessages();
};

Kind Regards, Rafal Kupka

kupson avatar Jul 03 '15 14:07 kupson

I just got stung by this. Causes hard to debug crashes of the entire application. Not cool.

panta82 avatar Oct 11 '15 11:10 panta82

Hit the same issue, looks like this module is not maintained anymore.

nebulade avatar Aug 10 '16 12:08 nebulade