(02.08.2022, 13:55)Daniel Wrote: The broker talks only via MQTT so you only need port 1883 or 8883. You don't have to open anything on LM just make sure nothing else is blocking it on the way as router or some firewall.
Thank you Daniel!
Okay, this is the html code I uploaded on the public directory of LM but it does not work... do you see anything strange ?
Code:
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<meta charset="utf-8">
<title>MQTT TEST</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
<script>
$(function(){
let client = mqtt.connect('ws://127.0.0.1:1883');
let topic = "floor1/room1"
let msg = '{"alias": "1/1/3", "value": 10}'
client.subscribe(topic);
client.publish(topic, msg);
client.on('message', function (topic, message) { // message is Buffer
console.log(message.toString());
});
});
</script>
</head>
<body>
</body>
</html>