Creating a shim for tornado with Autobahn|Python

#1

Hello!

I want to start by
saying what an awesome protocol (WAMP) and implementation you guys
have!

We would really love
to use autobahn as it has already made our prototype nearly trivial
to implement. The one hangup is we need to implement file
upload/download using HTTP. Ideally we would use twisted, however our
project is python3. I’ve done a lot of googling about the feasibility
of creating a shim for tornado and found these :

http://stackoverflow.com/questions/20657935/using-autobahn-twisted-to-establish-a-websocket-connection-in-tornado-http-handl

https://github.com/tavendo/AutobahnPython/issues/281

It looks like it
should be possible to create a little bit of code to interface the
event loop of tornado with the WAMP logic of autobahn, but I want to
clarify I couple of implementation details before I get too invested
in this.

Tornado supports
using an asyncio event loop, so in principle (I hope), both packages
should be able to work together. My question is, would the
integration then be as simple as creating a class which subclassed
both the WampWebsocketServerFactory and tornado’s WebSocketHandler
and provided a mapping? Or am I looking at the wrong implementation
layer and I need to go deeper?

Thanks for your
time!

-Evan

0 Likes

#2

Hi Evan,

> I want to start by saying what an awesome protocol (WAMP) and

implementation you guys have!

Thanks;)

We would really love to use autobahn as it has already made our
prototype nearly trivial to implement. The one hangup is we need to
implement file upload/download using HTTP. Ideally we would use twisted,
however our project is python3. I've done a lot of googling about the

What about using asyncio? The latter is already supported by AutobahnPython and runs on Python 3.

feasibility of creating a shim for tornado and found these :

http://stackoverflow.com/questions/20657935/using-autobahn-twisted-to-establish-a-websocket-connection-in-tornado-http-handl

This is running a Twisted-like event loop _under_ Tornado

http://www.tornadoweb.org/en/stable/twisted.html

I haven't tried that. Probably AutobahnPython works out of the box. However, you app will then depend on both Tornado and Twisted.

https://github.com/tavendo/AutobahnPython/issues/281

It looks like it should be possible to create a little bit of code to
interface the event loop of tornado with the WAMP logic of autobahn, but
I want to clarify I couple of implementation details before I get too
invested in this.

Tornado supports using an asyncio event loop, so in principle (I hope),
both packages should be able to work together. My question is, would the
integration then be as simple as creating a class which subclassed both
the WampWebsocketServerFactory and tornado's WebSocketHandler and
provided a mapping? Or am I looking at the wrong implementation layer
and I need to go deeper?

The way AutobahnPython supports multiple underlying networking frameworks is actually already using shims/mixins. E.g. all asyncio specific support code is here:

https://github.com/tavendo/AutobahnPython/tree/master/autobahn/autobahn/asyncio

If you want to add Tornado support, you would need to implement 3 files

autobahn/tornado/__ini__.py
autobahn/tornado/websocket.py
autobahn/tornado/wamp.py

using

http://www.tornadoweb.org/en/stable/concurrent.html#tornado.concurrent.Future

as the asynchronous abstraction.

Doing above would result in your app only depend on AutobahnPython besides Tornado (not Twisted nor asyncio), and AutobahnPython's WAMP implementation would use AutobahnPython's WebSocket implementation.

Is that would you are looking for?

Cheers,
/Tobias

···

Thanks for your time!

-Evan

--
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
<mailto:autobahnws+...@googlegroups.com>.
To post to this group, send email to autob...@googlegroups.com
<mailto:autob...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/autobahnws/d17ef886-5d83-4cc2-b258-4eb89f101163%40googlegroups.com
<https://groups.google.com/d/msgid/autobahnws/d17ef886-5d83-4cc2-b258-4eb89f101163%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

0 Likes