Reputation: 22760
I have installed a RabbitMQ docker image and have it up and running. My docker management console is also running on port 8080.
I run the docker with docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3
I am trying to run the following node code;
var amqp = require('amqplib/callback_api');
var connection = amqp.connect('amqp://localhost:5672',function(err,conn){
console.log(conn); });
However, conn is always undefined.
I have tried;
amqp://localhost:5672
amqp://localhost:15672
amqp://localhost
amqp://localhost:8080
but none of them work.
My rabbitmq manager says amqp is listening on 5672.
I have not got any other accounts other than the default guest account.
I'm not running visual studio code in admin mode.
The error I am getting is;
Error: Socket closed abruptly during opening handshake at Socket.endWhileOpening (C:\Users\sgrieger\Documents\Development\rabbitmq\node_modules\amqplib\lib\connection.js:259:17) at emitNone (events.js:111:20) at Socket.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)
Upvotes: 2
Views: 4550
Reputation: 22553
You aren't exposing the ports on the host when you run the docker image. You can do that with the -p
switch:
docker run -d --hostname my-rabbit -p 5672:5672 --name some-rabbit rabbitmq:3
Upvotes: 10