Reputation: 107
I use paho mqttws31.js (http://www.eclipse.org/paho/clients/js/) for receiving mqtt messages via websockets in a web-app. On pcs with different browsers(chromeium, firefox ...) everything works totally smooth without any errors. But when I use exactly the same source-code on mobile devices, like tablets or smartphones I don't receive retained messages. I subscribe for some retained topic inside of the onSuccess callback when I connect to the broker. But I don't receive the retained message most of the time. As mentioned this only happens on mobile devices.
Thanks in advance.
Upvotes: 2
Views: 2414
Reputation: 107
So for the ones who don't want to read all of the comments. This is seems to be a bug of mosquitto in conjunction with lighttpd, as websocket-provider.
What you can do:
either use: (simple way) HiveMQ(http://www.hivemq.com/mqtt-over-websockets-with-hivemq/) it supports websockets inherently, so the installation is a breeze, but it's not opensource and as it is written in Java I'm not sure if it is as fast as mosquitto, but I definitely don't know.
or: invest some time in compiling the newest version(1.4) of mosquitto, which also supports websockets natively: http://jpmens.net/2014/07/03/the-mosquitto-mqtt-broker-gets-websockets-support/ (but is not released so far) this version also seems to fix this problem. Installing newest mosquitto: http://goochgooch.wordpress.com/2014/08/01/building-mosquitto-1-4/
Edit0: I checked the speed and must say HiveMQ with websockets is way faster than mosquitto with websockets. I already noticed it when I connected via websockets, because there was a small latency. Then I sent 1000 values to the browser where they were returned to the subscribing client again. Hive seems to be 3-times faster than mosquitto (I have to commit that this may not be a reliable experiment). So for me my decision is obvious, as long as mosquitto doesn't work properly along with lighttpd-websocket support I will stay with hive. Would be nice to hear some opinions.
Edit1: I'm in a dilemma: Websocketsupport through lighttpd is very fast, way faster than the new mosquitto websocket support and faster than hivemq. As I am running the mqtt-broker on a raspberry, I'm dependent on good performance so neither of the discussed solutions of Edit0 is appropriate for me. But if I use lighttpd I face the originally described problem.
Does somebody have a more convenient solution?
Thx for your help.
Upvotes: 1