简体   繁体   English

JavaEE 6 Servlet用于长时间轮询

[英]JavaEE 6 Servlet for long polling

I've tried to create async-servlet for long-polling, using this tutorial on my Glassfish server, however it didn't work well, the POST requests were too long (timed out) and GET returned sometimes void response with "Error parsing XML file" firebug message. 我尝试在我的Glassfish服务器上使用本教程来创建用于长时间轮询的async-servlet,但是它不能很好地工作,POST请求太长(超时),并且GET返回有时带有“错误解析”的无效响应XML文件” firebug消息。 Can somebody please provide simple async-servlet for handling long-polling requests? 有人可以提供简单的async-servlet来处理长轮询请求吗?

It is better you move away from the servlet based approach if you want to implement a long polling solution. 如果要实现长轮询解决方案,最好放弃基于servlet的方法。 Netty is very good choice for such applications. Netty是此类应用程序的很好选择。 Just build a simple HTTP instance with child.keepAlive option in bootstrap kept to true (server doesnt close off the client connections). 只需使用bootstrap中的child.keepAlive选项构建一个简单的HTTP实例,并将其设置为true(服务器不会关闭客户端连接)。 That way you don't need to deal with the servlet containers time out and connection handling intricacies. 这样,您无需处理servlet容器超时和连接处理的复杂性。 Netty is an asynchronous IO framework and should give you great performance matrix. Netty是一个异步IO框架,应该为您提供出色的性能矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM