Created
February 3, 2014 23:39
-
-
Save claws/8794715 to your computer and use it in GitHub Desktop.
Simple WebSockets Proxy for a MQTT broker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gist demonstrates a simple method to create a WebSockets proxy for a MQTT broker. | |
# I use this method to provide a WebSockets interface for the Mosquitto MQTT broker. | |
# This lets my browser based MQTT applications to access my MQTT broker. | |
# I consider this approach simpler than the common alternative which is to run lighttpd | |
# with the mod_websocket addon which can be complex to setup. | |
# | |
# Dependencies are Python, Twisted and Autobahn. | |
# | |
# This example sets up a WebSockets server listening on localhost:9000. Messages received from | |
# WebSocket clients are forwarded to the MQTT broker using the endpointforward plugin provided | |
# by Autobahn. | |
# | |
# This example assumes that the MQTT broker is running on the localhost:1883. | |
# This example assumes that the WebSocket client is running the paho or mosquitto Javascript | |
# library, both of which use the `mqttv3.1` binary subprotocol. | |
twistd -n endpointforward --endpoint "autobahn:tcp\:9000:url=ws\://localhost\:9000:subprotocol=mqttv3.1" --dest_endpoint="tcp:127.0.0.1:1883" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment