mqttjs / MQTT.js

The MQTT client for Node.js and the browser
Other
8.58k stars 1.42k forks source link

Will and Testament on connection over Web Sockets #1278

Closed javiermelendezc closed 3 years ago

javiermelendezc commented 3 years ago

I'm currently trying to detect when a browser client connected to the broker loses connection due to network conditions

mqtt.connect("mqtt://xxxxxxxx:yyyy", {
            keepalive: 10,
            will: {
                topic: `test/status`,
                payload: "offline",
                qos: 0
            }
        })

Expected behavior

Current behavior

Is there any special consideration for will or testament when the connections is made over WS?

YoDaMa commented 3 years ago

@javiermelendezc let me try and help.

Is there any special consideration for will or testament when the connections is made over WS?

No. Connection over WS should be identical in nature to other protocols (regular mqtt, mqtts). So if there is inconsistencies, it is a bug.

First, could you provide a way to reproduce this? Including how you set up the Google Chrome broker, which is what I assume is receiving the LWT (last will and testament) message, and thus configuring it.

You can always check that LWT is being sent with the connect packet via the mqtt* debug logs. That will just check that the client is sending the LWT as part of the connect packet as per the MQTT spec. Other than that, how the broker handles LWT is based on the broker functionality.

YoDaMa commented 3 years ago

Closing due to inactivity.