Reputation: 153
I have a node.js app to be running with rabbitmq and mysql.
After setting everything up, when I do npm start
I have given the user administrator tag and permissions as rabbitmqctl set_permissions RABBIT_USERNAME "." "." ".*"
It shows this error :
> node app.js
13:43
Started database log (Mon Jan 29 2018 13:43:42 GMT+0530 (IST))
13:43
Started mailer log (Mon Jan 29 2018 13:43:44 GMT+0530 (IST))
13:43
Started messaging log (Mon Jan 29 2018 13:43:44 GMT+0530 (IST))
13:43
Started messaging log (Mon Jan 29 2018 13:43:44 GMT+0530 (IST))
13:43
Started database log (Mon Jan 29 2018 13:43:44 GMT+0530 (IST))
13:43
Started socket log (Mon Jan 29 2018 13:43:44 GMT+0530 (IST))
13:43 messaging:3000 is listening..
13:43 DB connected (7)
13:43 DB connected (6)
13:43 Error:
Expected ConnectionOpenOk; got <ConnectionClose channel:0>
Error: Expected ConnectionOpenOk; got <ConnectionClose channel:0>
at /PATH/node_modules/amqplib/lib/connection.js:167:14
at /PATH/node_modules/amqplib/lib/connection.js:159:12
at Socket.recv (/PATH/node_modules/amqplib/lib/connection.js:497:12)
at Object.onceWrapper (events.js:255:19)
at Socket.emit (events.js:160:13)
at emitReadable_ (_stream_readable.js:520:10)
at emitReadable (_stream_readable.js:514:7)
at addChunk (_stream_readable.js:280:7)
at readableAddChunk (_stream_readable.js:256:11)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onread (net.js:599:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! messaging@ start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the messaging@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mishal23/.npm/_logs/2018-01-29T08_13_45_095Z-debug.log
Upvotes: 11
Views: 13581
Reputation: 150
I faced same issue. I solved this by giving rabbitmq user proper permission for Virtualhosts. In my case user is admin and virtualhost is test_host
rabbitmqctl set_permissions -p /test_host admin ".*" ".*" ".*"
Upvotes: 0
Reputation: 31
In my case, the issue was related to heartbeat. You have to pass the heartbeat as a parameter to your connection URL:
amqps://user:password@domain/vhost_name?heartbeat=30
Upvotes: 2
Reputation: 31
Go to the rabbitmq dashboard > click admin menu > select your user from which you want to connect > click set permission button > restart server
Upvotes: 3
Reputation: 690
There is no enough context on how this happened so I'm making a few assumptions:
amqplib
for the connection. (Not an assumption)So the first thing you need to do is to create a user if you haven't already.
sudo rabbitmqctl add_user admin password
sudo rabbitmqctl set_user_tags admin administrator
Run this command if you haven't enabled the Management Dashboard
sudo rabbitmq-plugins enable rabbitmq_management
By default, it runs on port 15672
. So don't forget to open that port. And you can access this dashboard using your.server.ip.address:15672
.
Now in this Management Dashboard, go to the Admin
tab and on the right side, you'll see a link to Virtual Hosts
.
There will be one virtual host named /
and user guest
(that you cannot access without localhost). Now create a new virtual host and check if it has the same user as you just created a few moments back (admin
in this case).
Use the string below to connect to the server instead of amqp://localhost
amqp://admin:[email protected]/vhost_name
You can use this example (or any other examples) for the rest of the things...
I hope this helps!
Upvotes: 15