1

I've encountered following error message while connection our external RabbitMQ with NodeJS as follow:

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:205:27) {
  errno: 'ECONNRESET',
  code: 'ECONNRESET',
  syscall: 'read'
}

and my nodejs code is as follow:

const amqp_url = "amqp://un:pw@sb-mq.com:9901/my-vhost";
amqp.connect(amqp_url, function (error0, connection) {
  if (error0) {
    throw error0;
  }
  connection.createChannel(function (error1, channel) {
    if (error1) {
      throw error1;
    }
    var queue = 'hello';
    var msg = 'Hello World!';
    channel.assertQueue(queue, {
      durable: false
    });
    channel.sendToQueue(queue, Buffer.from(msg));
    console.log(" [x] Sent %s", msg);
  });
  setTimeout(function () {
    connection.close();
    process.exit(0);
  }, 500);
});

But the thing is when I've setup RabbidMQ locally with same configuration but using default port (like amqp://un:pw@localhost:5672/my-vhost), it was working perfectly. Please let me know how to troubleshoot that one, thanks.

PPShein
  • 13,309
  • 42
  • 142
  • 227

2 Answers2

2

"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection.

see How do I debug error ECONNRESET in Node.js?

about RabbitMQ check if rabbitmq actually is active in that port, just:

telnet sb-mq.com 9901

from your client machine and check the firewall configuration. You may have another service running on 9901

ECONNRESET is network problem, rabbitmq can work in different ports without problems

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
0

I found that issue has been resolved when I've tried to use amqps instead of amqp.

PPShein
  • 13,309
  • 42
  • 142
  • 227