提问人:Bruce 提问时间:2/19/2019 最后编辑:Bruce 更新时间:2/20/2019 访问量:523
如何让Apache反向代理服务器支持长轮询连接?
How to make the Apache reverse proxy server to support the long-polling connection?
问:
我们在 Tomcat 8 服务器上有一个 Apache Comet servlet,用于长轮询连接,如下所示。
public class Connect extends HttpServlet implements CometProcessor {
public void event(CometEvent event) throws IOException, ServletException {
HttpServletRequest request = event.getHttpServletRequest();
HttpServletResponse response = event.getHttpServletResponse();
if (event.getEventType() == CometEvent.EventType.BEGIN) {
event.setTimeout(300000);
...
} else if (event.getEventType() == CometEvent.EventType.ERROR) {
event.close();
} else if (event.getEventType() == CometEvent.EventType.END) {
event.close();
}
}
}
Tomcat8 服务器 .xml 的连接器如下所示
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="90000"
redirectPort="8443" URIEncoding="UTF-8"/>
彗星连接将在 300 秒后超时。当客户端尝试直接连接到 Tomcat 时,这有效。(http://IP:8080/Connect)。
但是,如果我们设置了 Apache 反向代理,则连接将始终在 60 秒后超时。Apache proxypass 设置如下
ProxyTimeout 310
ProxyPass /Connect http://localhost:8080/Connect connectiontimeout=60 timeout=310 keepalive=On ttl=350
ProxyPassReverse /Connect http://localhost:8080/Connect
如何使长轮询连接在反向代理上工作?
谢谢
答: 暂无答案
评论