You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to connect to my mosquitto broker.
The problem im facing, as soon as the "connect" package is writen, the tcp socket is closed.
I guess this happens because the package is invalid/the broker expect something else?
Code i used for testing:
constnet=require("net");constmqtt=require("mqtt-packet");constparser=mqtt.parser({protocolVersion: 4});constsocket=net.Socket();socket.on("close",()=>{console.log("connection closed");});socket.on("data",(data)=>{console.log(">",data);parser.once('packet',packet=>{console.log(packet)});parser.parse(data);});socket.on("connect",()=>{console.log("Connected to tcp://open-haus.lan:1883");letdata=mqtt.generate({cmd: 'connect',protocolId: 'MQTT',// Or 'MQIsdp' in MQTT 3.1 and 5.0protocolVersion: 4,// Or 3 in MQTT 3.1, or 5 in MQTT 5.0clean: true,// Can also be falseclientId: 'my-device-test-node',//keepalive: 0, // Seconds which can be any positive number, with 0 as the default settingwill: {topic: '#',payload: Buffer.from('dead'),// Payloads are buffers}});socket.write(data,()=>{console.log("connect has writen",data)});});socket.connect(1883,"open-haus.lan");
I try to connect to my mosquitto broker.
The problem im facing, as soon as the "connect" package is writen, the tcp socket is closed.
I guess this happens because the package is invalid/the broker expect something else?
Code i used for testing:
Output:
The "data" event on the tcp socket isnt even fired.
As seen in this graphic, after the tcp socket is established, a connect packet is send to the broker:
I dont get anything back.
The text was updated successfully, but these errors were encountered: