Search code examples
node.jssocketsdestroy

TypeError: Object #<Socket> has no method 'destory'


I'm having trouble handling a ECONNREFUSED error from my net.createConnection in node.js.

When I connect I get ECONREFUSED (which is fine), and I handle it this way:

testSocket.addListener('error', function(message) {
    testSocket.destory();
});

That then gives me the error: TypeError: Object # has no method 'destory'.

My goal is to close the socket based on the error, which will then start a reconnect process.

Thanks in advance!


Solution

  • Did you mean destroy? You spelt it incorrectly (distORy)