eclipse-paho / eclipse-paho/paho.mqtt.javascript

MESSAGE_TYPE.CONNACK endless loop

Open
#185 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
466
PR merge metrics
No merged PRs in 30d

Description

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 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:

`
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + "-" + s4() + "-" + s4() + "-" +
s4() + "-" + s4() + s4() + s4();
}

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.