我们在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 server.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
我们如何使长轮询连接在反向代理上起作用?
谢谢