tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nabble User <>
Subject Anyone using Tomcat 6 Comet with Apache mod_proxy?
Date Tue, 10 Aug 2010 18:46:13 GMT
I have a CometProcessor servlet similar to the one in the sample here:

One difference is that we close the writer after sending the message in the
MessageSender thread.  It all works fine hitting Tomcat directly.  However,
I'd like to proxy the requests through Apache (for various reasons).  So, I
setup a ProxyPass like this:

ProxyPass /comet http://localhost:8081/CometApp/
ProxyPassReverse /comet http://localhost:8081/CometApp/

This seems to work sometimes but other times I get a 502 response and see
the following in the Apache log:

[Tue Aug 10 16:00:45 2010] [error] [client xx.xx.xx.xx] (104)Connection
reset by peer: proxy: error reading status line from remote server localhost
[Tue Aug 10 16:00:45 2010] [error] [client xx.xx.xx.xx] proxy: Error reading
from remote server returned by /comet/wait

On my local Windows box I added the following line to the apache config to
diable keepalives and the problem went away in that environment:
SetEnv proxy-nokeepalive 1

I figured this was an OK workaround until I have time to come back and
figure out the real issue.

I just released the app to a Centos 5.4 server and started seeing the 502s
again.  So, I disabled keepalives in the apache config there as well.
However, in that environment with the keepalives disabled, the response to
the client is not closed until the Comet Request timeout is exceeded (30
seconds).  So, that hack won't fly (even temporarily).

Now I am back to trying to figure out why this fails with keepalives on.  It
seems like on some requests Apache thinks the connection is still valid but
Tomcat thinks otherwise.  On Centos I can easily duplicate but hitting the
url 8 times.  One the 9th time I get the 502.  I will then get 8 x 502
responses then 8 good responses and so on.  I can see 8 connections open
(netstat) after the first 8 hits and I I get the 502s I see the connections
terminated one by one.

I tried messing with various timeouts, etc to no avail.

I also notice that if I do something like the following in the servlet
(instead of queuing up the connections and sending a result later) I can hit
the url all day long with no problem:

if (event.getEventType() == CometEvent.EventType.BEGIN) {

    PrintWriter writer = response.getWriter();
    writer.println("<!doctype html public \"-//w3c//dtd html 4.0
    writer.println("<head><title>JSP Chat</title></head><body
    writer.println("Message Sent:" + sentCount);


So, it seems to only be an issue when sending the message and closing the
response writer from the "queue" connections.

Here are the Centos 5.4 environment details:

Apache 2.2.3
Tomcat 6.0.26
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

Anyone have any ideas what might be going on here?  Anyone have a
configuration like this actually working?

Thanks in advance!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message