Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I specify RabbitMQ credentials in node.js?

I started to use rabbit.js to connect to RabbitMQ from a node.js application.

I'm blocked at:

Error: Channel closed by server: 403 (ACCESS-REFUSED) with message "ACCESS_REFUSED -operation not permitted on the default exchange"
    at Channel.C.accept (/.../rabbit.js/node_modules/amqplib/lib/channel.js:398:24)
    at Connection.mainAccept [as accept] (/.../rabbit.js/node_modules/amqplib/lib/connection.js:63:33)
    at Socket.go (/.../rabbit.js/node_modules/amqplib/lib/connection.js:448:48)
    at Socket.EventEmitter.emit (events.js:92:17)
...

which is expected, since the instance of RabbitMQ I use is configured to require the publishers and subscribers to provide credentials before being able to use the message queue, and guest account is disabled.

The official documentation of rabbit.js has no mention of credentials. Google searches for “rabbit.js specify credentials” and “rabbit.js login password” were inconclusive.

Are credentials supported by rabbit.js? If not, what other RabbitMQ clients for node.js support them?

like image 576
Arseni Mourzenko Avatar asked Jul 24 '14 22:07

Arseni Mourzenko


People also ask

How do I use RabbitMQ with node js?

Create an account in their website and create an instance. Once you create an instance, click on the “RabbitMQ Manager” button. This should open the standard RabbitMQ admin console. Let us create a durable queue in the same console.

Which of the following is the client library for Node JS to integrate with RabbitMQ?

rabbit. js: message patterns in node. js using RabbitMQ.

How do I connect to RabbitMQ?

In order for a client to interact with RabbitMQ it must first open a connection. This process involves a number of steps: Application configures the client library it uses to use a certain connection endpoint (e.g. hostname and port) The library resolves the hostname to one or more IP addresses.


1 Answers

So I never used rabbit.js myself, but after diving into the code, it seems to be using amqplib. The code that parses it can be seen here and it seems it's calling the standard nodejs URL module. So perhaps you can try something like this:

amqp://user:[email protected]/vhost 

Hope it helps!

Cheers.

like image 130
marcelog Avatar answered Sep 20 '22 23:09

marcelog