标签: comet

刷新图像PHP和Javascript

我正在使用一个名为APE的Comet,Realtime引擎,我使用jQuery来刷新PHP图像.最初我加载这样的图像:

<div id="container">
<img src="image.php" style='background: url(../assets/load.gif) no-repeat center center;margin-left:42px;' alt=' Loading ...' width="500px" height="300px" />
</div>
Run Code Online (Sandbox Code Playgroud)

然后当我收到一个事件时,我这样做:

$("#container").empty();
$("#container").html('<img src="image.php?device='+device+'" style="background: url(../assets/load.gif) no-repeat center center;margin-left:42px;" width="500px" height="300px" alt=" Loading ..."/>');
Run Code Online (Sandbox Code Playgroud)

device是我从事件中收到的var,所以例如我得到device1,一切正常(图像实际上是图表),标题更改为"device1",并绘制最后5分钟

但是,我的问题是每次收到一个事件,在这个初始事件之后,日期仍然是相同的五分钟时间.我的设备每次都是相同的,但在我的脚本中我计算5分钟前到当前时间的时间纪元,但是这个脚本似乎没有更新图像.是缓存还是什么?

我已经尝试在页面顶部使用它:

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>
Run Code Online (Sandbox Code Playgroud)

我可以等待大约10分钟,发送一个事件,但时间段仍然是从初始加载,我认为"empty()"将清除容器,重新加载图像,因此重新运行脚本.任何建议都会有帮助!

谢谢

javascript php jquery image comet

2
推荐指数
1
解决办法
1932
查看次数

未定义的方法`close_connection_after_writing'

我使用Faye在多人游戏的轨道3上进行了项目.错误

block in close': undefined methodclose_connection_after_writing'为nil:NilClass(NoMethodError)

from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket/api.rb:89:in `call'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket/api.rb:89:in `close'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/gems/faye-websocket-0.4.5/lib/faye/websocket.rb:198:in `fail'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/connection.rb:155:in `unbind'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:1417:in `event_callback'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@global/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/bin/rackup:19:in `load'
    from /Users/ostap/.rvm/gems/ruby-1.9.3-p125@chats/bin/rackup:19:in `<main>'
Run Code Online (Sandbox Code Playgroud)

在我的faye服务器启动后使用命令

rackup faye.ru -s thin -E production

这样的错误怎么办?怎么样呢?我该怎么处理?

ruby-on-rails comet faye

2
推荐指数
1
解决办法
599
查看次数

为什么浏览器不允许您打开常规连接而不是Ajax或Comet?

如果要在浏览器和服务器之间打开双向连接,唯一的选择是轮询(锤击服务器),或使用彗星(狡猾且容易断开连接).

为什么浏览器不能让你打开普通的TCP连接?没有这种能力有什么实际好处吗?

browser ajax comet

1
推荐指数
1
解决办法
185
查看次数

建议Comet服务器

我正在寻找基于Linux的开源Comet服务器.目前,看看Hookbox - 但是就像在Python中一样,我关注性能.Python而不是C++对性能有很大影响吗?

开发人员估计,当拥有100个频道时,它的性能达到每秒约100个请求...不是很快: - |

你能建议最积极支持/使用的彗星服务器是二进制(=更快),易于集成和(有点)轻量级?此外,Java/.NET不在这里.

我们的目标是每台服务器大约10k +连接,10-20k通道每秒大约2000-5000条消息.

comet hookbox

1
推荐指数
1
解决办法
2785
查看次数

Servlet 3.0:无法发送异步响应?

我无法为用户建立AsyncContexts并使用它们向他们推送通知.在页面加载时,我有一些jQuery代码来发送请求:

$.post("TestServlet",{
    action: "registerAsynchronousContext"
        },function(data, textStatus, jqXHR){
            alert("Server received async request"); //Placed here for debugging   
  }, "json");
Run Code Online (Sandbox Code Playgroud)

在"TestServlet"中,我在doPost方法中有这个代码:

HttpSession userSession = request.getSession();
String userIDString = userSession.getAttribute("id").toString();

String paramAction = request.getParameter("action");

if(paramAction.equals("registerAsynchronousContext"))
{              
    AsyncContext userAsyncContext = request.startAsync();

    HashMap<String, AsyncContext> userAsynchronousContextHashMap = (HashMap<String, AsyncContext>)getServletContext().getAttribute("userAsynchronousContextHashMap");
    userAsynchronousContextHashMap.put(userIDString, userAsyncContext);
    getServletContext().setAttribute("userAsynchronousContextHashMap", userAsynchronousContextHashMap);

    System.out.println("Put asynchronous request in global map");
}

    //userAsynchronousContextHashMap is created by a ContextListener on the start of the web-app
Run Code Online (Sandbox Code Playgroud)

但是,根据Opera Dragonfly(像Firebug这样的调试工具),服务器在发送请求后大约30000ms会发送一个HTTP 500响应.

使用userAsyncContext.getResponse().getWriter().print(SOME_JSON)创建的任何响应,并在浏览器未收到HTTP 500响应之前发送,我不知道为什么.只有当处理AsyncContext的"if"语句中的所有代码都不存在时,浏览器才会使用常规响应对象发送响应(response.print(SOME_JSON)).

有人可以帮我吗?我有一种感觉,这是因为我误解了异步API的工作原理.我认为我可以将这些AsyncContexts存储在全局映射中,然后检索它们并使用它们的响应对象将内容推送到客户端.但是,似乎AsyncContexts不能写回客户端.

任何帮助都会被贬低.

java asynchronous comet java-ee servlet-3.0

1
推荐指数
1
解决办法
2713
查看次数

我可以使用jQuery预过滤器来检测readyState == 3的onreadystatechange事件吗?

我正在尝试在jQuery中实现XHR流Comet技术,但是在检测onreadystatechange事件时遇到了一些麻烦.我正在使用Firefox 4.0.1.

我正在使用预过滤器(自jQuery 1.5起可用)来修改本机XHR对象,特别是为事件添加事件处理程序onreadystatechange.我在http://jsfiddle.net/Rdx6f/上有一个粗略的实现.该事件被触发时,该代码会将文档附加到XHR对象readyStateresponseText属性onreadystatechange.但奇怪的是,它似乎只onreadystatechangereadyState1 时检测到事件.

换句话说,onreadystatechange当XMLHttpRequest对象处于"打开"状态(readyState 1)时,jQuery似乎检测到事件,但是当XHR对象处于"收到的头"状态(readyState 2),"loading"(readyState 3)时,jQuery似乎没有检测到事件. ),也没有"完成"(readyState 4).

奇怪的是,如果我alert()在事件处理程序中,那么我确实看到onreadystatechangereadyState为1,2,3和4时的处理.请参阅http://jsfiddle.net/Rdx6f/1/.与http://jsfiddle.net/Rdx6f/相同的代码,只是alert()而不是附加到文档.

我还可以在本机JavaScript中检测1,2,3或4 onreadystatechange时的事件readyState- 请参阅http://jsfiddle.net/d7vaH/.(该代码几乎是从Dylan Schiemann在"Even Faster Websites"一书的第115页上实现的XHR流程中逐字记录的.)

我只是在这里做错了,比如使用jQuery的Ajax前置错误或者出现JavaScript错误?这可能是jQuery中的一个错误吗?

jquery comet onreadystatechange http-streaming

1
推荐指数
1
解决办法
1640
查看次数

轨道发射问题:"ConfigParser.NoSectionError:No section:'formatters'"

我试图让Orbited开始,但不幸的是我遇到了不止一些问题!首先,easy_install的问题(已解决).然后,继续http://mischneider.net/?p=125的说明.但在使用时,orbited -c orbited.cnf我得到以下内容:

Traceback (most recent call last):
  File "C:\Python27\Scripts\orbited-script.py", line 8, in <module>
    load_entry_point('orbited==0.7.11beta3', 'console_scripts', 'orbited')()
  File "C:\Python27\lib\site-packages\orbited-0.7.11beta3-py2.7.egg\orbited\star
t.py", line 133, in main
    logging.config.fileConfig(options.config)
  File "C:\Python27\lib\logging\config.py", line 70, in fileConfig
    formatters = _create_formatters(cp)
  File "C:\Python27\lib\logging\config.py", line 106, in _create_formatters
    flist = cp.get("formatters", "keys")
  File "C:\Python27\lib\ConfigParser.py", line 567, in get
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'formatters'
Run Code Online (Sandbox Code Playgroud)

这是我的配置文件(orbited.cnf):

[listen]
http://:9000
stomp://:61613

[access]
* -> localhost:61613

[global]
session.ping_interval = 300
Run Code Online (Sandbox Code Playgroud)

(编辑:我可能需要一个[格式]部分?)我什么都没有,我发现大部分资源都指向orbited.org,因为我对轨道感兴趣的那一天就已经失败了.请帮帮我!我真的想开始使用酷炫的django应用程序!

python django comet stomp orbited

1
推荐指数
1
解决办法
9134
查看次数

理解一行示例代码

我试图根据我的需要修改这个例子,但特别是有一条线让我难过.((Action<List<MessageInfo>>)parm)(msgs);聊天服务器中的这一行对我来说毫无意义.我可以看到它对类型进行了类型转换(msgs)((Action<List<MessageInfo>>)parm);,但它似乎根本没有做任何事情.

我希望有人可以帮助我理解这一点,因为我感觉这是我对这个难题所遗漏的最后一件事之一......

亲切的问候.

c# comet long-polling asp.net-mvc-3

1
推荐指数
1
解决办法
109
查看次数

如何在Google应用引擎上实现COMET/Server Push?

我是Stack overflow和Google app引擎的新手.在Java Web应用程序中,ddo如何实现COMET,在连接超时方面存在限制,或者如果不可能,可以在appengine上实现websocket服务器吗?

java ajax google-app-engine comet websocket

1
推荐指数
1
解决办法
1464
查看次数

如何使用comet(在nginx中禁用输出缓冲,它通常在apache中工作,但不能在nginx中工作)?

我的网站上有一个以彗星为主导的聊天脚本

我的服务器配置是带有PHP-FPM的NGINX,我也在不同的端口上安装了apache.

当我尝试在Apache上运行聊天脚本时,我将缓冲区(我的输出缓冲区大小为1 KB)当我用1024个字符填充它时,它会自动刷新它在apache中.

但在nginx中却没有.

我的代码与此非常相似

<?php

// this is to fill the buffer and start output; and it works on apache normally
echo str_repeat(" ",1024); 


while($condition){

  // Some code here...
  $messages = getMessagesFromDatabase();

 if($messages){
  echo "output";   // output works on apache but not nginx
  flush();
  ob_flush();
 }

 usleep(500000); // 0.5 Second

}


?>
Run Code Online (Sandbox Code Playgroud)

在我的nginx配置中,我关闭了gzip,关闭了proxy_buffering,

有没有办法避免在nginx中缓冲,我在stackoverflow中搜索了很多,但我无法达成解决方案

请注意:我不想在我的所有php配置中关闭缓冲我只想在聊天脚本中发生这种情况

php comet nginx output-buffering

1
推荐指数
1
解决办法
2237
查看次数