While simple request / response "AJAX" and long-polling may do the trick for most of the things we want to do, it'd be nice to sort out a standardized model for dealing with real-time components.
- Live-updating recent changes
- Live notification of user messaging
- User chat, or per-page chat (may be a bad idea, but just as a possible option)
- Real-time editor sharing (though this may go over another channel, such as the home-rolled mobwrite server)
The Django community hasn't settled on a single, cohesive way to deal with real-time interactions yet. Where possible, it would be good for us to help push Django in a direction here. Most Django-based projects that are doing real-time stuff are using a wide array of different technologies all meshed together.
SocketIO traditionally uses a node.js-based server implementation. Nevertheless, the client-side JS interface has gained significant traction and the API makes a lot of sense. There's many SocketIO implementations in different languages.
The django-socketio project aims to seamlessly intergrate Django projects with websockets-y stuff. It's based on gevent-socketio. It provides an easy, all-in-one pip-based installation (after installing two standard event libraries system-wide) and a simple manage.py command to spin up the socketio server.
It looks great, but I was unable to get any of the examples to run due to issues with the underlying gevent-socketio server.
Relevant bugs blocking exploration:
- https://bitbucket.org/Jeffrey/gevent-socketio/issue/6/021-websocket-transport-not-working django-socketio is still working because it's using the gevent-socketio stable.
- Can we block in these django_socketio.events decorators? Ideally, the answer would be yes.
15:36 < philipn> codysoyland: in your gevent+socketio+django blog post, what would happen if we did an expensive, blocking ORM call in the socketio() function? The same thing that would happen if we did similiar in an event decorator in django-socketio, right? 15:37 < traviscline> db calls are greenable with mysql and postgres 15:46 < codysoyland> philipn: yes, it would block further execution on all greenlets unless you install a green-ified database adapter as traviscline mentioned 16:23 < philipn> codysoyland: hmm, so it would make sense for this django-socketio library to detect the db connector and then try to greenify it if the appropriate libs are installed
- How painful is making authenticated sockets work correctly? This is important.
- See also http://dbinit.com/blog/going-green/ psycopg greenlet
- https://github.com/stephenmcd/django-socketio/issues/17 Will be the basis for Philip's further exploration
See https://github.com/MrJoes/tornadio2. It doesn't seamlessly intergrate with Django but it may be more stable. The big question is whether we can block in the methods on MyRouter that we define.
Hookbox is an independent, python-based (using eventlet) evented server and message queue that's designed to handle most all of the use cases real-time stuff. The goal of Hookbox is to allow your web application (php, django, rails, etc.) to handle all of the logic pertaining to authentication, authorization, logging, message transformation, etc, while still hiding the hard parts of Comet.
Hookbox will call webhooks when certain events happen.
I was able to get it running with modest effort. Here's a video of a real-time equalizer thing:
Pros: Really easy to understand programming model. Easy to get running.
Cons: Despite temendious promise, the project was abandoned early on by its main developer, due to a new startup of his. The project has since been picked up and seems to be re-invigorated, maybe.
To investigate: how easy is authentication?