paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

MESSAGE_TYPE.CONNACK endless loop

Open nakvic opened this issue 6 years ago • 4 comments

Once connection established, paho client executes onSuccess callback endlessly, that is the following part of code is executed over and over again (paho-mqtt.js:1269):

case MESSAGE_TYPE.CONNACK: this._connectTimeout.cancel(); if (this._reconnectTimeout)

However, server sends CONNACK only once: 1545401288: New client connected from <IP> as CLIENT-3331ad84-92c0-514f-a26e-c3c8fd186b76 (c1, k60, u''). 1545401288: Sending CONNACK to CLIENT-3331ad84-92c0-514f-a26e-c3c8fd186b76 (0, 0)

Browser: Chrome

Server: Eclipse Mosquitto 1.5.5

OS: Raspberry Jessie

Client js code:

`

host = <removed>;
port = <removed>
username = <removed>;
password = <removed>;
var client = new Paho.Client(host, port, "CLIENT-" + guid());

// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;

// connect the client
client.connect({
    onSuccess:onConnect,
    userName:username,
    password:password,
    useSSL:true
});

// called when the client connects
function onConnect() {
    // Once a connection has been made, make a subscription and send a message.
    console.log("onConnect");
}

// called when the client loses its connection
function onConnectionLost(responseObject) {
    if (responseObject.errorCode !== 0) {
        console.log("onConnectionLost:"+responseObject.errorMessage);
    }
}

// called when a message arrives
function onMessageArrived(message) {
    console.log("onMessageArrived:"+message.payloadString);
}

`

Regards, Victor

nakvic avatar Dec 21 '18 14:12 nakvic

3 months later and I am having this same issue. Has a fix been determined yet?

Josh798 avatar Mar 25 '19 13:03 Josh798

Hi everybody, Once connection established, paho client executes onSuccess callback endlessly, code is executed over and over again (paho-mqtt.js:1269):

I am stick also for several month I have exactly the same issue on firefox and on chrome either with my code or with Victor code, is it fixed? CPU 100% and high memory leakeage

My configuration: server: Eclipse Mosquitto version 1.5.6 starting, OS: is Debian version 8.11"jessie"

Browser: Firefox developer edition 68.0b4 (64-bit) os: windows 10

Thanks to all by advance! Jean-Philippe

here is my code, but same result with Josh code ========= MY CODE ============== var client = new Paho.MQTT.Client("10.8.0.1",Number(9001),"/test","test"); // set callback handlers client.onConnectionLost = onConnectionLost; client.onMessageArrived = onMessageArrived;

// connect the client client.connect({onSuccess:onConnect}); // try to fix by : client.connect({onSuccess:onConnect,mqttVersion:3}); => same issue

// called when the client connects function onConnect() { // Once a connection has been made, make a subscription and send a message. console.log("onConnect"); // => Endless loop on this connect client.subscribe("#");// Doesn't depend if commented or no }

// called when the client loses its connection function onConnectionLost(responseObject) { if (responseObject.errorCode !== 0) { console.log("onConnectionLost:"+responseObject.errorMessage); } }

// called when a message arrives function onMessageArrived(message) { console.log("onMessageArrived:"+message.payloadString); }

jphi09 avatar May 27 '19 02:05 jphi09

Same =(

acervantess avatar Jul 01 '19 15:07 acervantess

I noticed Im having this issue too, presumably after CloudMQTT (my broker provider) updated their Mosquitto version? Everything worked fine before that.

Funny enough, even the CloudMQTT website displays this behavior.

cok666n avatar Apr 10 '20 11:04 cok666n