I am using MQTT and below are options that I am passing to connect
var options = {
keepalive: 10,
clientId: '',
protocolId: 'MQTT',
protocolVersion: 3,
clean: true,
reconnectPeriod: 20000,
connectTimeout: 30 * 1000,
protocol:'mqtt',
rejectUnauthorized: false
}
const client = mqtt.connect('mqtt://192.168.127.13:1883',options); -> my local mosquitto broker
can any one help, why I am getting "Client
AB#9368700
same here Any update?
const us = {
clientId: 'xiot_' + Math.random().toString(16).substr(2, 8),
username: mqtt.username,
password: mqtt.password,
useSSL: false,
onSuccess: onAction,
onFailure: onAction,
protocolId: 'MQTT',
protocolVersion: 5,
rejectUnauthorized: false,
clean: true,
reconnectPeriod: 20000,
connectTimeout: 30 * 1000,
protocol: 'mqtt',
};
let client1 = mqtt1.connect('mqtt://192.168.1.16:1883/',us);
Same here!
So I had the same issue, new mosquitto server installed on OSX with homebrew and using react-native.
For some reason no native mqtt connection could be made so I used websockets.
You'll need to add to mosquitto.conf bellow #port 1883
listener 1883
protocol mqtt
listener 8883
protocol websockets
When you start mosquitto it should say:
1583550048: mosquitto version 1.6.8 starting
1583550048: Config loaded from /usr/local/etc/mosquitto/mosquitto.conf.
1583550048: Opening ipv6 listen socket on port 1883.
1583550048: Opening ipv4 listen socket on port 1883.
Then connect using:
const client = mqtt.connect('ws://localhost:8883', options);
Hope this helps someone.
I was getting the error "Client disconnected due to protocol error" in the below scenario:
Fix:
Review the mosquitto.conf file. Specify the proper certificates to be used by the broker for authenticating the clients (sub or pub)
Just to add a trail of this, you will also encounter a protocol error if you try to use a subscription_identifier that's not between the allowed range 1 ~ 2^28-1
same here Any update?
const us = { clientId: 'xiot_' + Math.random().toString(16).substr(2, 8), username: mqtt.username, password: mqtt.password, useSSL: false, onSuccess: onAction, onFailure: onAction, protocolId: 'MQTT', protocolVersion: 5, rejectUnauthorized: false, clean: true, reconnectPeriod: 20000, connectTimeout: 30 * 1000, protocol: 'mqtt', }; let client1 = mqtt1.connect('mqtt://192.168.1.16:1883/',us);
Same Issue for me, when I try to use the Websocket solution it works but i'm not in charge of the mosquitto server. I would like to use native MQTT protocol for this.
bump?
seems like a pervasive bug. it might be related to some bugs that have been recently fixed in mqtt-packet. It looks like a new version of mqtt-packet (patch-update) was released today. Can you try and see if you're using it and if the problem persists? The mqtt-packet version is 6.8.1.
Hello! Any updates on this? I seem to have the same issue.
seems like a pervasive bug. it might be related to some bugs that have been recently fixed in
mqtt-packet. It looks like a new version ofmqtt-packet(patch-update) was released today. Can you try and see if you're using it and if the problem persists? Themqtt-packetversion is6.8.1.
I used the 6.9.0 version when I found the bug.
So I had the same issue, new mosquitto server installed on OSX with homebrew and using react-native.
For some reason no native mqtt connection could be made so I used websockets.
You'll need to add to mosquitto.conf bellow
#port 1883listener 1883 protocol mqtt listener 8883 protocol websocketsWhen you start mosquitto it should say:
1583550048: mosquitto version 1.6.8 starting 1583550048: Config loaded from /usr/local/etc/mosquitto/mosquitto.conf. 1583550048: Opening ipv6 listen socket on port 1883. 1583550048: Opening ipv4 listen socket on port 1883.Then connect using:
const client = mqtt.connect('ws://localhost:8883', options);Hope this helps someone.
Yup, this worked. 馃帀馃帀
Most helpful comment
same here Any update?