Using django as a socket server and not HTTP server

35 views
Skip to first unread message

Idan Shimon

unread,
Aug 5, 2015, 12:24:39 PM8/5/15
to Django users
Hi i am interested to setup my own socket protocol against a peripheral device
The socket server would be online and exposed to the web, however it will not work on http.

Can i use django / nginx to manage the socket sessions ? while i focus on functionality ?

Can someone redirect me to a proper package ?

My system connectivity is this way:
DEVICE ----- SOCKET CONN --- SERVER ---- DJANGO ---- MYSQL | S3 AWS

Thanks, 
Idan  

Javier Guerra Giraldez

unread,
Aug 5, 2015, 1:03:56 PM8/5/15
to django...@googlegroups.com
On Wed, Aug 5, 2015 at 10:14 AM, Idan Shimon <idan...@gmail.com> wrote:
> Hi i am interested to setup my own socket protocol against a peripheral
> device
> The socket server would be online and exposed to the web, however it will
> not work on http.


not as it is currently.

the issue is that Django is a WSGI app, and Nginx doesn't pass TCP
connections, it parses HTTP and passes it to the Python stack (via
FastCGI, uWSGI, HTTP, etc). Even if the backend connection is HTTP,
it's a "reconstructed" http after being interpreted by the frontend.

if your protocol is not HTTP but it's roughly request-response, then
you might be able to create a frontend that calls Django (or any WSGI
app) in the back. Maybe by hacking gunicorn, or creating a uWSGI
plugin, or using the new async capabilities in the latests Python
versions... but it would be the current stack as is.

--
Javier

Carlos Andre

unread,
Aug 5, 2015, 7:40:29 PM8/5/15
to django...@googlegroups.com
have a framework to work like this, twistter


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFkDaoS5CHn_dGc6-0QjOkqD-6JMqxMdoe5VGoRUE3VJFcDmpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages