TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The easiest way to add WebSockets to Django

50 点作者 mcpherson超过 11 年前

4 条评论

falcolas超过 11 年前
No, it&#x27;s really not that easy, sorry.<p>Looking at the code, you&#x27;re not actually doing anything with websockets here. There&#x27;s no handshake parsing, there&#x27;s no open socket object to pass data back and forth on, there&#x27;s nothing actually websockety about this.<p>Instead, you seem to have a simple ajax endpoint.<p>Or am I missing something?<p>[EDIT] Clarifying why I said it&#x27;s not that easy, since that seems snarky as I read it again. To properly do websockets in Django, you have to write your own runserver, which allows processes up the stack to capture the raw socket, perform the websocket handshake methods, and do proper parsing of the incoming data to break the messages on the sentinel values.<p>I recently tried to do this, and the one package that did this wouldn&#x27;t work with Django 1.6, and we would have to give up our flup runfcgi, which I wasn&#x27;t ready to do.
评论 #7131027 未加载
nilsbunger超过 11 年前
This could be useful. A few questions:<p>1) can you describe the tornado part of the system? The blog post isn&#x27;t really clear on that.<p>2) how do you associate websocket sessions with browser sessions?<p>3) how do you handle server-to-client notifications? ie. a celery task completes and you want to notify the client.<p>4) Is XSS a concern?
vivekprakash超过 11 年前
This question is more related to websockets. I have seen that they use different protocol and doesn&#x27;t work behind proxies or firewalls most of the time. How do you handle this?
评论 #7131160 未加载
jpdlla超过 11 年前
Author here. Let me know if you have any questions or feedback.
评论 #7130867 未加载
评论 #7131255 未加载