I see you've already posted the question HERE and this one should be closed as duplicate, but I suppose you're desperate for an answer at this point. Where did you get the port value of 1883
from? I suppose you just copied it from the sample JD Allen have provided in the comments. Ofcourse it is not gonna work, it was just a sample value.
So, according to their Official guide for Node-Red you should be using port 8883
. Also, I am pretty sure your clientId
is not id
, you should fetch that from your hub.
If you're still getting an error related to the handshake, you're most probably having protocol version mismatch on your server and client. Checkout the docs for the npm package and more specifically the section about web sockets.
This should pretty much solve the handshake problem. From then on, you'll have other issues as you're not subscribing to any topics in your code. Once again, check the mqtt
's package docs.
This question should help you as well: MQTT.js not connecting from websockets.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…