简体   繁体   English

在node.js中写入ECONNRESET错误和套接字连接检查

[英]write ECONNRESET error and socket connection checking in node.js

I get this error occasionally when running my node.js script. 运行node.js脚本时偶尔会出现此错误。

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? 第三, 是一个简单的尝试捕获socket.write语句,足以处理这个错误? 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 我们已经通过http-proxy看到了它,问题在这里报道: https//github.com/nodejitsu/node-http-proxy/issues/331

nodejs would throw if there "error" (and only "error") event is not handled. 如果没有处理“错误”(并且只有“错误”)事件,则nodejs将抛出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM