Reputation: 5932
I am trying to connect to rabbitmq broker (rabbitmq-server-3.8.0) by nodejs and amqplib/callback_api
library so after install amqplib
library with :
npm i amqplib
I wrote this code :
const amqp = require("amqplib/callback_api");
amqp.connect('amqp://guest:guest@xxxx:5672', (err, conn) => {
if (err) throw err;
else console.log(`Connect to brocker success!`);
})
As official site say:
By default, the guest user is prohibited from connecting from remote hosts; it can only connect over a loopback interface (i.e. localhost).
It is possible to allow the guest user to connect from a remote host by setting the loopback_users configuration to none.
In %APPDATA%\RabbitMQ\
location of my broker server it did not exist rabbitmq.conf
file so i'd created this file just by this content:
loopback_users = none
C:\Users\tazik.WIN-LKH5BTVHRCM\AppData\Roaming\RabbitMQ>dir
Volume in drive C has no label.
Volume Serial Number is A852-F618
Directory of C:\Users\tazik.WIN-LKH5BTVHRCM\AppData\Roaming\RabbitMQ
10/13/2019 11:39 AM <DIR> .
10/13/2019 11:39 AM <DIR> ..
10/12/2019 02:05 PM 3 advanced.config
10/13/2019 11:41 AM <DIR> db
10/12/2019 02:07 PM 23 enabled_plugins
10/13/2019 10:37 AM <DIR> log
10/13/2019 10:22 AM 21 rabbitmq.conf
3 File(s) 47 bytes
4 Dir(s) 116,768,235,520 bytes free
C:\Users\tazik.WIN-LKH5BTVHRCM\AppData\Roaming\RabbitMQ>
Now after run nodejs code i still got this error:
2019-10-13 10:37:46.818 [info] <0.895.0> accepting AMQP connection <0.895.0> (94.182.192.28:25759 -> *********:5672)
2019-10-13 10:37:46.834 [error] <0.895.0> Error on AMQP connection <0.895.0> (94.182.192.28:25759 -> ******:5672, state: starting):
PLAIN login refused: user 'guest' can only connect via localhost
2019-10-13 10:37:46.849 [info] <0.895.0> closing AMQP connection <0.895.0> (94.182.192.28:25759 -> ******:5672)
Upvotes: 0
Views: 4066
Reputation: 5148
Have you restarted after configuration? Also, check if RABBITMQ_CONFIG_FILE env is set to the location you placed the config file:
Open the "RabbitMQ Command Prompt (sbin dir)"
.\rabbitmq-service.bat stop
.\rabbitmq-service.bat remove
Run the following commands in the previous shell:
.\rabbitmq-service.bat install
.\rabbitmq-service.bat start
After that, you should be able to connect
Upvotes: 1