Django有没有办法打开HTTP长轮询连接? [英] Does Django have a way to open a HTTP long poll connection?

查看:298
本文介绍了Django有没有办法打开HTTP长轮询连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将连接打开,直到发生事件。

解决方案

看看 Django /彗星(推):所有邪恶最少?彗星在Python中的最新推荐? - COMET是ajax长轮询的另一个名称。 p>

显然,最常见的方法是不直接在django中进行,而是在额外的守护进程的帮助下(可能是因为Apache对很多长时间的连接不好)。现在nodejs + socketio是非常受欢迎的(甚至可以使用WebSockets) - 你只需要找到一个很好的方法来传递数据之间的两件事情。如果它是单向的(例如只是广播到所有连接的客户端),redis pubsub队列不是一个坏的选择。



但是 http://code.google.com/p/django-orbited/ 可能是最djangoish的解决方案。


Leave the connection open, until an event occurs.

解决方案

Have a look at Django / Comet (Push): Least of all evils? or The latest recommendation for Comet in Python? - COMET is another name for "ajax long-polling".

Apparently the most common approach is not doing it directly in django but with the help of an additional daemon (probably because e.g. Apache doesn't do well with lots of long-living connections). Nowadays nodejs+socketio is pretty popular for this (and it can even use WebSockets) - you just need to find a nice way to pass data between the two things. If it's unidirectional (e.g. just broadcasts to all connected clients) a redis pubsub queue is not a bad option for this.

But http://code.google.com/p/django-orbited/ is probably the most djangoish solution.

这篇关于Django有没有办法打开HTTP长轮询连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆