Fixing AMQJS0008I Socket closed error in PAHO JS + Activemq
Asked Answered
I

2

10

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

Ikey answered 17/3, 2016 at 18:49 Comment(1)
yes seems like a wrong formatted message, as AWS IOT core's messages end up fine, they need to be well formatted objects, I'm on it, will post the answer once I solve itWalkerwalkietalkie
H
3

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.

Hanger answered 15/10, 2016 at 10:1 Comment(3)
What do you mean having a permission? can you give me a code sample please? Do you mean just subscribing to a topic and simply sending to that topic? I'm not using mqtt over a secure connection nor with authentication so can't understand if there's another "permissions" layer, as I couldn't find a solution, please point me in the right direction with an example as I'm stuck on this for a few days now taWalkerwalkietalkie
So the issue was happening to me because I created a user on my cloudmqtt server but did not give that user permission to pub / sub to specific topics. Look for 'Users and ACL' on CloudMqtt. Can you use other clients to connect like MqttLens Google Chrome extension?Hanger
Ah I did isolate myself on this, this morning talking through the clients code with my junior dev I realised that both clients were setup with same ID and that was my problem... Rubber duck effect...Walkerwalkietalkie
O
1

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
Octal answered 27/6, 2021 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.