10

I'm trying to find some "django-socketio" repo to use in my project. I using django 1.10 and python3. I really searched but I do not found working examples with python3.

My poor workaround

  • I started node project and put socket.io inside route
  • In my django view I send returning data to node route with my django session
  • I manage session coming from django inside my node and emit inside route to client.

This work but I can't believe this is a good solution.. Anyone have other ideas? Or working examples with python3 and socketio?

Thanks!

2

2 Answers 2

8
+25

If you want to use Websockets and Django you should consider https://github.com/django/channels. The alternative in Python would be using python tornado http://www.tornadoweb.org/en/stable/ or aiohttp (Python3.4+) http://aiohttp.readthedocs.io/en/stable/. Many of the implementations of Django with asynchronousity through gevent are outdated, experimental or abandoned, I found this https://github.com/jrief/django-websocket-redis but it uses Redis so no reason to not going back to django-channels.

In my opinion, as Socket.io is a layer over Websockets you will not find any project that supports fully the Socket.io spec as a ws server in Python as it is a native Node.js not officially ported to Python project, at least the latest one you are probably using, if you really need Socket.io features stick to Node.js and create a simple REST API in Django to load the backend data asynchronously from Nodejs (the REST django API will always be synchronous by nature), this is the best shot you would likely have.

Sign up to request clarification or add additional context in comments.

3 Comments

But I just want a manager to control sessions of django in my node server. I don't need official projects, just new projects to work toguether and make this. Maybe I need use flask like Agam Banga says..
Well, if you want Django to manage socketio sessions with Django sessions the answer is kind of what I told you. If you are opened to change Django for Flask then flask-socketio can be a solution, but it has little to nothing to do with your original question that was tagged for Django framework, Django and Flask are very different frameworks so Session management between them are different matters. If your priority is having socketio as real time protocol while keeping python as backend, then go for Flask, it's a valid solution (although it's based on gevent, which you should study apart)
could u add python-socketio too? thanks
2

https://github.com/django/channels/blob/master/docs/getting-started.rst

django-channels works with python3 and django >=1.8 :)

And you can change pip to pip3

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.