admin管理员组

文章数量:1424458

I just got started with nodejs and using it to create a server. Clients connect to it using socket.io, receive jobs to proceess, and send the results back to the nodejs server.

However the server will crash occassionally with the following error:

node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: connect ECONNREFUSED
    at errnoException (net.js:614:11)
    at Object.afterConnect [as onplete] (net.js:605:18)

I have no idea what is causing this.

I just got started with nodejs and using it to create a server. Clients connect to it using socket.io, receive jobs to proceess, and send the results back to the nodejs server.

However the server will crash occassionally with the following error:

node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: connect ECONNREFUSED
    at errnoException (net.js:614:11)
    at Object.afterConnect [as onplete] (net.js:605:18)

I have no idea what is causing this.

Share Improve this question edited Apr 29, 2012 at 12:02 Jeff LaFay 13.4k14 gold badges73 silver badges102 bronze badges asked Apr 29, 2012 at 1:17 NyxynyxNyxynyx 63.9k163 gold badges507 silver badges856 bronze badges 4
  • 1 Would you be able to share your source code at all? – Menztrual Commented Apr 29, 2012 at 1:46
  • Where is a good place to post the source? I want to be able to take it down after a while though – Nyxynyx Commented Apr 29, 2012 at 10:33
  • We mean posting blocks of code that's related to the error. Seeing that you have 1k reputation, I'm surprised you're not familiar with posting code examples. – Jeff LaFay Commented Apr 29, 2012 at 12:03
  • Sorry for my ignorance, but I am not able to tell which part of my code is causing the error. net.js probably came with node.js and isnt written by me... – Nyxynyx Commented Apr 29, 2012 at 12:47
Add a ment  | 

2 Answers 2

Reset to default 3

ECONNREFUSED means you tried to make a connection to another machine but your connection was refused - either no one was listening or a firewall blocked you.

I have seen this using http, but I think it could also happen using straight sockets.

You are probably struggling with node.js dying whenever the server you are calling refuses to connect. Try this:

process.on('uncaughtException', function (err) {
    console.log(err);
}); 

It will just log the errors and keep your service up and running.

本文标签: javascriptOccassional ECONNREFUSED errorsStack Overflow