Brandon Wilson Brandon Wilson - 7 months ago 66
Javascript Question

Paho Websocket Connection Closes Upon Second Connection

I have built an MQTT server to test of M2M messages and I built a small Javascript application using Paho and I am able to connect, subscribe, and publish messages on a single connection. However, once I start up a new tab or browser, the first connection closes. I am not sure why and I happen when I have a new connection, even from another computer.


You can not use hard coded client ids, the best option is to use a random number or millisecond timestamp based id.


var clientID = "web" + new Date().getTime();

var client = new Paho.MQTT.Client('localhost',1884,clientID);