Nodejs: Handshake terminated by server: 403 rabbitmq
我正在尝试通过nodejs和
我写了这段代码:
1 2 3 4 5 6 | 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!`); }) |
正如官方网站所说:
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.
在我的代理服务器的
abbitMQ\\
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | C:\\Users\\tazik.WIN-LKH5BTVHRCM\\AppData\ oaming\ abbitMQ>dir Volume in drive C has no label. Volume Serial Number is A852-F618 Directory of C:\\Users\\tazik.WIN-LKH5BTVHRCM\\AppData\ oaming\ abbitMQ 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\ oaming\ abbitMQ> |
现在在运行nodejs代码后,我仍然收到此错误:
1 2 3 4 | 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) |
配置后您重新启动了吗? 另外,检查是否将RABBITMQ_CONFIG_FILE env设置为放置配置文件的位置:
打开" RabbitMQ命令提示符(sbin目录)"
1 2 3 4 5 | .\ abbitmq-service.bat stop .\ abbitmq-service.bat remove |
在先前的外壳中运行以下命令:
1 2 3 4 5 | .\ abbitmq-service.bat install .\ abbitmq-service.bat start |
之后,您应该可以连接