endpointforward plugin support for other binary protocols

#1

Hi,

I am trying to create a simple websockets proxy, using Python, for the mosquitto MQTT broker. This would simplify my system by removing the need for me to run the lighttpd webserver with mod_websocket to act as the websockets proxy. The proxy needs to stream binary MQTT messages received from a Javascript client, over a websocket, to a MQTT broker and back again. The endpointforward twistd plugin within autobahn Python seemed like the perfect one-liner solution for me. However, this does not work because the paho and mosquitto MQTT javascript libraries both initiate a ‘mqttv3.1’ subprotocol to transfer binary MQTT messages. The endpointforward plugin is hard coded to only accept ‘binary’ and ‘base64’ protocol.

I have managed to build the websockets proxy but it necessitated duplicating quite a bit of autobahn endpointforward internals because there does not seem to be an easy way to provide alternative supported binary protocols label down to the wrapped websocket factory and protocol - both of which use their own hard coded list of supported protocols.

If the endpointforward plugin accepted an argument to specify additional supported binary protocols I think I could use a simple one-liner that invokes the endpointforward plugin.

Is this change to the endpointforward plugin feasible to include in the Autobahn Python product?

Regards,
Chris

0 Likes

#2

I have made appropriate changes and submitted a pull request to the AutobahnPython project that allows for other binary compatible WebSocket subprotocols to be supplied to the endpointforward twistd plugin. This change now allows me to run a simple one-liner to create a websockets proxy in front of a MQTT broker using:

twistd -n endpointforward --endpoint “autobahn:tcp:9000:url=ws://localhost:9000:subprotocol=mqttv3.1” --dest_endpoint=“tcp:localhost:1883”

···

On Monday, February 3, 2014 11:03:47 AM UTC+10:30, chris laws wrote:

Hi,

I am trying to create a simple websockets proxy, using Python, for the mosquitto MQTT broker. This would simplify my system by removing the need for me to run the lighttpd webserver with mod_websocket to act as the websockets proxy. The proxy needs to stream binary MQTT messages received from a Javascript client, over a websocket, to a MQTT broker and back again. The endpointforward twistd plugin within autobahn Python seemed like the perfect one-liner solution for me. However, this does not work because the paho and mosquitto MQTT javascript libraries both initiate a ‘mqttv3.1’ subprotocol to transfer binary MQTT messages. The endpointforward plugin is hard coded to only accept ‘binary’ and ‘base64’ protocol.

I have managed to build the websockets proxy but it necessitated duplicating quite a bit of autobahn endpointforward internals because there does not seem to be an easy way to provide alternative supported binary protocols label down to the wrapped websocket factory and protocol - both of which use their own hard coded list of supported protocols.

If the endpointforward plugin accepted an argument to specify additional supported binary protocols I think I could use a simple one-liner that invokes the endpointforward plugin.

Is this change to the endpointforward plugin feasible to include in the Autobahn Python product?

Regards,
Chris

0 Likes

#3

I have made appropriate changes and submitted a pull request to the
AutobahnPython project that allows for other binary compatible WebSocket
subprotocols to be supplied to the endpointforward twistd plugin. This
change now allows me to run a simple one-liner to create a websockets
proxy in front of a MQTT broker using:

twistd -n endpointforward --endpoint
"autobahn:tcp\:9000:url=ws\://localhost\:9000:subprotocol=mqttv3.1"
--dest_endpoint="tcp:localhost:1883"

Hi Chris,

Awesome! Thanks for the PR .. merged. Will be in AutobahnPython 0.8.1 ..

/Tobias

···

Am 03.02.2014 13:27, schrieb chris laws:

On Monday, February 3, 2014 11:03:47 AM UTC+10:30, chris laws wrote:

    Hi,

    I am trying to create a simple websockets proxy, using Python, for
    the mosquitto MQTT broker. This would simplify my system by removing
    the need for me to run the lighttpd webserver with mod_websocket to
    act as the websockets proxy. The proxy needs to stream binary MQTT
    messages received from a Javascript client, over a websocket, to a
    MQTT broker and back again. The endpointforward twistd plugin within
    autobahn Python seemed like the perfect one-liner solution for me.
    However, this does not work because the paho and mosquitto MQTT
    javascript libraries both initiate a 'mqttv3.1' subprotocol to
    transfer binary MQTT messages. The endpointforward plugin is hard
    coded to only accept 'binary' and 'base64' protocol.

    I have managed to build the websockets proxy but it necessitated
    duplicating quite a bit of autobahn endpointforward internals
    because there does not seem to be an easy way to provide alternative
    supported binary protocols label down to the wrapped websocket
    factory and protocol - both of which use their own hard coded list
    of supported protocols.

    If the endpointforward plugin accepted an argument to specify
    additional supported binary protocols I think I could use a simple
    one-liner that invokes the endpointforward plugin.

    Is this change to the endpointforward plugin feasible to include in
    the Autobahn Python product?

    Regards,
    Chris

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes