I get this error occasionally when running my node.js script.
events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: write ECONNRESET
at errnoException (net.js:768:11)
at Object.afterWrite (net.js:592:19)
What causes this error? I read someplace that this is caused due to attempting to write data to a closed socket. Is that right?
If that is the case, How do I check if a socket connection is active? I found this SO question here, but no one had answered there.
And thirdly, is a simple try catch around the socket.write statement, enough to handle this error? Or does it emit error events which I must handle?
we've seen it with http-proxy and the issue was reported here: https://github.com/nodejitsu/node-http-proxy/issues/331
nodejs would throw if there "error" (and only "error") event is not handled.