Open kbariotis opened 6 years ago
I made it connect but then when I am receiving a message:
Do you any idea what would that be?
Hey not sure what the root cause is but the source of the error is at https://github.com/larrytin/paho.mqtt.javascript/blob/master/src/mqttws31.js#L1145
Maybe you could try breakpointing at the above line to see if it helps with identifying the source of the issue. Looks like there might be an issue with the data being sent from the server but hard to tell without further debugging.
Excerpt from L1145:
ClientImpl.prototype._on_socket_message = function (event) {
this._trace("Client._on_socket_message", event.data);
// Reset the receive ping timer, we now have evidence the server is alive.
this.receivePinger.reset();
var messages = this._deframeMessages(event.data);
for (var i = 0; i < messages.length; i+=1) {
this._handleMessage(messages[i]);
}
}
I tried and I didn't really get anything useful. Also, Paho is your library's dependency so I don't see a reason why would that message come from the server.
I will try again though, thank you.
That function is called when the underlying websocket has received a complete packet. Since its a length of undefined error I am assuming messages is probably undefined. This function is called before my library processes the message.
I am using Paho as the mqtt client but technically any client that handles mqtt messages should work but will require adjusting this library to the new client. AWS IOT only supports the mqtt protocol over websocket.
Ill try to reproduce the issue tonight and see what I can learn.
There is something wrong with the paho-mqtt
package. The version on NPM is 1.0.4 but the repository has 1.0.3 as the latest version. You can also see changes they have made to fix issues probably with the import method. Those changes are not on my project due to the wrong version published on the registry.
I will continue investigating.
It seems like the Paho client is not being loaded correctly. Also, in your example you are loading the source of the module, but I had to load the
dist
folder because I don't have typescript runtime.Sidenote: I am using the hybrid mode.