Fixing AMQJS0008I Socket closed error in PAHO JS + Activemq

Viewed 9446

Sometimes I am getting AMQJS0008I Socket closed error very frequently on onConnectionLost. I am using latest Activemq version.

Does it happens because of some wrong formatted message received because sometime it go all messages nicely and sometimes in between it show the error

2 Answers

I was receiving this message when the user that I logged in with did not have permission to access a topic that I tried to subscribe to.

The easiest solution to try would be to make sure that the user your MQTT client is connecting with has permission to read that topic if the client is subscribing. If the client is trying to publish then make sure that user has permission to write to that topic.

If you have already added the necessary permissions then make sure you have typed the topic name correctly.

On my case, the issue was that I was trying to connect PAHO Client to MQTT Broker but brocker wasn't configured to accept Web Sockets (WS://).

Solution: Edit mosquitto.conf and add:

listener 9001
protocol websockets

listener 1883
protocol mqtt
Related