Unable to connect to Apache ActiveMQ with Node.js

冷暖自知 提交于 2019-12-06 16:11:20

Solution

After asking around in the ActiveMQ forums, it does turn out that @Tim was correct. To quote the user Gordon Sim-2:

As of 5.14 (...) ActiveMQ requires a SASL layer, even if you use ANONYMOUS to authenticate. The examples for clients often don't explicitly authenticate in any way (...)

To fix this there are two options.

Option 1 - change code

The first one is to change the code, which is what I was looking for:

To have the amqp10 client use a SASL layer, just specify a saslMechanism override on the connect e.g.

client.connect(uri, {'saslMechanism':'ANONYMOUS'})

This approach was suggested by the creator of yet another AMQP 1.0 Node.js library called rhea and I highly recommend that if you are reading this, to check it.

Option 2 - change broker config files

The second one, as Tim suggested, is to change the broker configuration files. I recommend reading his post if you opt for this approach as it is more complete.

The most likely issue is that the client is not using a SASL based authentication request on the connect and is just trying to connect directly. The broker defaults to requiring the client be using SASL in it's opening handshake even if the authentication mechanism is only 'Anonymous' so that the client can be validated against any broker security policy that is in place.

You can disable this check by adding wireFormat.allowNonSaslConnections=true to the broker's AMQP TransportConnector configuration and then see if you can connect. This might be a short term solution to get you going however on a production broker you should not be using that option and should have a valid security policy in place with user / password authentication.

Read about broker configuration here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!