Keeping connection open in Django without websockets

让人想犯罪 __ 提交于 2019-12-12 04:09:48

问题


I have a mini computer that does not support websockets that I would like to receive push notifications from a server.

The issue is that after the client connects to the server, the server responds and then closes the connection. This makes it so the client has to continually reconnect to the server to get new information.

Is there a way using Django to allow the connection to be left open and then have the server publish data to the client?


回答1:


Django is primarily a request/response framework and as such does not have support for real duplex communication.

Socket.IO is the de facto library that makes websocket-like functionality cross-browser (IE5.5+), using real websockets as a transport if the browser allows it, falling back to HTTP long-polling or whatever else if it doesn't. For various options on integrating Socket.IO with Django, read this.



来源:https://stackoverflow.com/questions/12146501/keeping-connection-open-in-django-without-websockets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!