mqtt-react-hooks
mqtt-react-hooks copied to clipboard
Client disconnecting and reconnecting using local mosquitto broker
Hello,
I'm using docker container running a mosquitto broker. Works fine with mqtt.js library. However, when I try to use the Connector provider it disconnects/reconnects on a loop. Here's the output:
mosquitto | 1668119874: New client connected from ::ffff:172.23.0.1:57598 as mqttjs_41060487 (p2, c1, k0).
mosquitto | 1668119874: No will message specified.
mosquitto | 1668119874: Sending CONNACK to mqttjs_41060487 (0, 2)
mosquitto | 1668119874: Client mqttjs_41060487 closed its connection.
I'm using vite and added the following line to the vite config resolve: { alias: { mqtt: "mqtt/dist/mqtt.js" }
I got it to work with test.mosquitto.org but then ran into the client undefined issue
https://github.com/VictorHAS/mqtt-react-hooks/issues/41
I'd love to get this working locally. Here' is my mosquitto.conf
persistence false
listener 1883
allow_anonymous true
listener 8083
protocol websockets
Here is a similar issue with a Node Red client:
https://github.com/eclipse/mosquitto/issues/2381
Thanks!
client?.off("message", callback); runs everytime I publish or do hot reload. not sure why its there but it was disconnecting on boot and when a message is sent and when I edit the code during local dev.