question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection.end() causes an emit of ECONNRESET

See original GitHub issue

When I run some of the tests, e.g

node test/test-basic-return.js

I get

/home/ch/node_modules/amqp/node_modules/longjohn/dist/longjohn.js:184
        throw e;
              ^
Error: read ECONNRESET
    at errnoException (net.js:901:11)
    at onread (net.js:556:19)
---------------------------------------------
    at module.exports.run (/home/ch/node_modules/amqp/test/harness.js:49:23)
    at Object.<anonymous> (/home/ch/node_modules/amqp/test/test-basic-return.js:1:84)
    at Module._compile (module.js:456:26)
    at Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Module._load (module.js:312:12)
    at Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

It seems it is connected to #295 and #246, however the code from #248 does not solve it.

It is a hell of a bug, because it caused me to look for a few hours for a bug in exchange.publish, and then it turned out it is some networking stuff happening upon connection.end().

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
glenjamincommented, Feb 1, 2014

My branch doesn’t stop other bits of the system from trying to send data once the socket is closed - I was a bit lazy there.

Say you have a continuous publish(), then you trigger a close - the publish that happens after socket.end() / connectionCloseOk will cause the exception described above.

Possible Solutions:

  1. Make sure your app stops trying to send data after a close
  2. Extend the branch to make node-amqp throw a more obvious error in this scenario
  3. Call socket.end() and socket.destroy() in the handler - this should stop data being sent after the close think.
0reactions
pruthvireddypuresoftwarecommented, Sep 11, 2018

test/test-basic-return.js: Error: read ECONNRESET at TCP.onread (net.js:660:25)

at Object.run (/node/node-amqp/test/harness.js:49:23)
at Object.<anonymous> (/node/node-amqp/test/test-basic-return.js:1:22)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)

Facing above issue in debian, nodejs v10.8 and RabbitMQ 3.3.5. Downloaded the current commit and connection.js file has destroy function called. case methods.connectionCloseOk: debug && debug(“Received close-ok from server, closing socket”); this.socket.end(); this.socket.destroy(); break;

Please suggest me any other solution. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I debug error ECONNRESET in Node.js?
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one...
Read more >
How do I debug error ECONNRESET in Node.js?
“ECONNRESET” means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one...
Read more >
Errors | Node.js v19.3.0 Documentation
ECONNRESET (Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on...
Read more >
node:events:505 throw er; / unhandled 'error' event ^ error
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one...
Read more >
15 Common Error Codes in Node.js and How to Fix Them
1. ECONNRESET ... If this exception occurs when making a request to another server, you should catch it and decide how to handle...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found