We are looking at using MQTT as the messaging protocol on a new device we\'re building. We\'d also like a web interface for the device. Does anyone know if you can impleme
This link (Download codes) is useful. Download it and modify this file mosq-mqttws31.html. Instead of the embedded java script library use this cdn
https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js
and the client instantiation should be client = new Paho.MQTT.Client("test.mosquitto.org", 8080,"myclien256tiffffd_" + parseInt(Math.random() * 100, 10));
Yes, as mentioned in Steve-o's comment MQTT via websockets is very possible.
There are 2 options at the moment
To answer your second question lighttpd has a websockets module that can be used to do forwarding to an existing broker with details here.
I've not been able to find anything for Apache that doesn't need you to write your own library to do the forwarding.
IBM has released a WebSockets based JavaScript client. It is open-source on Eclipse Paho.
Git repository: http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.javascript.git/
Tutorial is here. https://www.ibm.com/developerworks/community/blogs/c565c720-fe84-4f63-873f-607d87787327/entry/how_to_prog_javascript?lang=en
The blog by jpmens is a good starting point to get mosquitto setup with websocket feature. He's client javascript code based on Paho is on github.
This blog "How to run your web server and MQTT WebSockets broker on the same por" explains two ways for the server side:
To extend hardillbs answer:
There is a third option now:
HiveMQ supports native websockets without the need for any external web server. It works perfectly with the Javascript client of Eclipse Paho.
If you want to try it out, the public MQTTDashboard (which uses HiveMQ under the hoods) supports websockets on port 8000.
Disclosure: I am one of the developers of HiveMQ
We've had good experience using WSS, the WebSocket to TCP Gateway (for MQTT). It means running a separate process, but that does avoid having to change Apache's configuration. WSS also has support for TLS.