-
-
Save kleisauke/632b0f687bc9762e911d901e09e0026a to your computer and use it in GitHub Desktop.
EMQ X Broker - LWT WebSocket bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>MQTT.js LWT</title> | |
</head> | |
<body> | |
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script> | |
<script> | |
var client = mqtt.connect('ws://<BROKER URL HERE>:8083', { | |
will: { | |
topic: 'lwt', | |
payload: '1', | |
qos: 1, | |
retain: false | |
} | |
}); | |
client.on('connect', () => { | |
console.log('Connect success'); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>MQTT.js LWT</title> | |
</head> | |
<body> | |
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script> | |
<script> | |
var client = mqtt.connect('ws://<BROKER URL HERE>:8083'); | |
client.on('connect', () => { | |
console.log('Connect success'); | |
client.subscribe( | |
'lwt', | |
{qos: 1}, | |
(err) => { | |
console.log(err || 'Subscribe success') | |
}, | |
); | |
}); | |
// Handle message event | |
client.on('message', (topic, message) => { | |
console.log('Received message', topic, ':', message.toString()); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment