Socket.IO (or Engine.IO) client in Python

964 views
Skip to first unread message

Robertjd

unread,
Feb 13, 2012, 2:48:13 PM2/13/12
to Socket.IO
We have a python app that is uses websockets to communicate with a
Socket.IO server. But, as we all know, web sockets are problematic
(proxies, firewalls) and will be for some time. And that, of course,
is the beauty of the Socket.IO javascript client: transport selection
and fallback

We need transport selection and fallback in our Python client.
Writing an implementation of the Socket.IO / Engine.IO protocol seems
to be the most logical choice.

Is anyone else in need of this right now? I see one discussion here:
http://groups.google.com/group/socket_io/browse_thread/thread/3efec26cb2db79e9/73034700b4a058af?

There are several server implementations, such as:

https://github.com/MrJoes/tornadio2
https://bitbucket.org/Jeffrey/gevent-socketio

But I'm not finding any client implementations. Is there something
I'm not finding?

Thanks for reading,
Robert

Roey Berman

unread,
Feb 13, 2012, 4:50:39 PM2/13/12
to sock...@googlegroups.com
I don't know if there's a socket.io client for python, but hopefully this will help.


You can also use a message queue like Rabbitmq to communicate with your socket.io servers (which is my preferred option).

laxmikant

unread,
Feb 13, 2012, 11:27:46 PM2/13/12
to sock...@googlegroups.com
Hi Robert,

          Thanks for this link. This will be really helpful for me.  However I am interested in Socket.IO  & Node.js with Django Framework and Python.  I was circling around on google a month before,  but i hv not got anything better. Just not more than a board  "Work in progrss with Django".

Thanks in advance for better help.



        Regards,
       Laxmikant

Robertjd

unread,
Feb 13, 2012, 8:17:42 PM2/13/12
to Socket.IO
Hi Roey, thanks for the ideas.

Even with Rabbit MQ it seems that the basic problem still exists on
the side of the python client: if I can't bring up a simple socket
connection to the MQ server I need to try another transport (and
another MQ gateway) such as HTTP polling.  This brings me back to
needing the essence of the Socket.IO client (transport priority and
fallback) as a Python library.

On Feb 13, 1:50 pm, Roey Berman <roey.ber...@gmail.com> wrote:
> I don't know if there's a socket.io client for python, but hopefully this
> will help.
>
> https://github.com/Lawouach/WebSocket-for-Pythonhttps://github.com/oberstet/Autobahnhttps://github.com/LearnBoost/socket.io-spec
>
> You can also use a message queue like Rabbitmq to communicate with your
> socket.io servers (which is my preferred option).
>
>
>
>
>
>
>
> On Mon, Feb 13, 2012 at 9:48 PM, Robertjd <rjdam...@gmail.com> wrote:
> > We have a python app that is uses websockets to communicate with a
> > Socket.IO server.  But, as we all know, web sockets are problematic
> > (proxies, firewalls) and will be for some time.  And that, of course,
> > is the beauty of the Socket.IO javascript client: transport selection
> > and fallback
>
> > We need transport selection and fallback in our Python client.
> > Writing an implementation of the Socket.IO / Engine.IO protocol seems
> > to be the most logical choice.
>
> > Is anyone else in need of this right now?  I see one discussion here:
>
> >http://groups.google.com/group/socket_io/browse_thread/thread/3efec26...
> > ?

deakblue

unread,
Feb 14, 2012, 9:19:33 PM2/14/12
to Socket.IO
Oops, Gmail 'reply' opened a new subject. Anyway, reposting:

I see that you're looking for fallbacks. I wrote a client that's
websocket only -- seems you did too. I'm interested in a library
grade client as well, fallbacks or otherwise. I'm posting a rough
draft here of my client for the interested.

The client API is reworked towards Kivy and it's still very very rough
and it ONLY does websockets.


http://pastebin.com/WcrcPZKE
Depends:
Autobahn
Twisted (Zope)
Kivy

The reason for the Autobahn dependency is that Twisted Websockets
aren't mainline:
http://twistedmatrix.com/trac/browser/branches/websocket-4173-2

IIRC, they're quarantined until the spec is settled, so I opted for
Autobahn instead. Probably switching to the Twisted version would
look almost the same though.

The client API is different. I'm trying something like:
socket.event_name.msg -- a property that is observably changed (kivy
has observable property 'events')
socket.event_name.emit(object) -- a method for emitting an event using
a JSON-able object
socket.event_name.emit(object, callback)
socket.status -- an observable property for "disconnect","connect"
etc.

Anyway, I'm posting a pastebin just for research purposes, I don't
expect it to be much general use yet, but it might be interesting to
other people doing client development.

I plan to eventually release a quality version with the traditional
API and a separated Kivy decoration.

NOTE: after yesterday's 1.1.0 release of Kivy, this doesn't work
anymore owing to this issue:
https://github.com/kivy/kivy/issues/372


Good luck,
-db-


Reply all
Reply to author
Forward
0 new messages