users@glassfish.java.net

Re: (Comet) Running GlassFish with mod_proxy

From: <glassfish_at_javadesktop.org>
Date: Wed, 02 Jul 2008 18:07:04 PDT

Hi.
By Jeanfrancois's help, I can find out the reason.
#thanks a lot Jeanfrancois!

The cause will be mod_proxy.
The mod_proxy don't release the connection between glassfish and apache.
So, The glassfish cannot detect the browser's exit.

For example, I did the below command.
#netstat -an | grep <<glassfish_port>> | wc -l
the result is:
Direct access ---------------------------
- before aceess:4
- access glassfish:5
- exit browser:4
mod_proxy access ------------------------
- before aceess:4
- access mod_proxy:5
- exit browser:5
------------------------------------------
the number was same in spite of close the connection.
it means mod_proxy hasn't closed the connection
and we need to find how to configure mod_proxy in a way that
when the client close the connection, mod-proxy also close the
connection between Apache and GlassFish.

the mod_proxy's options are here.
http://httpd.apache.org/docs/2.2/en/mod/mod_proxy.html
I had try "keepalive", "timeout", "max", "smax"...but result is same.

My test servlet is here:
-----------------------------------------------
package sample;

import com.sun.enterprise.web.connector.grizzly.comet.*;
import java.io.*;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;

public class CometServlet extends HttpServlet {
    
    private String contextPath;
    private Logger logger = Logger.getLogger("servlet");
   
    @Override
    public void init(ServletConfig config) throws ServletException {
        contextPath = config.getServletContext().getContextPath() + "/CometServlet";
        CometContext context = CometEngine.getEngine().register(contextPath);
        context.setExpirationDelay(12 * 60 * 60 * 1000);
        logger.info("init");
    }
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        CometHandler<PrintWriter> handler = new CometHandler<PrintWriter>() {
            PrintWriter writer;
            public void attach(PrintWriter writer) {
                this.writer = writer;
            }
            public void onEvent(CometEvent arg0) throws IOException {}
            public void onInitialize(CometEvent arg0) throws IOException {}
            public void onTerminate(CometEvent arg0) throws IOException {
                onInterrupt(arg0);
            }
            public void onInterrupt(CometEvent event) throws IOException {
                this.writer.close();
                event.getCometContext().removeCometHandler(this);
                logger.info("onInterrupt!");
            }
        };
        handler.attach(response.getWriter());
        CometContext context = CometEngine.getEngine().getCometContext(contextPath);
        context.addCometHandler(handler);
        logger.info("connect!");
    }
}
-----------------------------------------------

If anyone know the setting, please tell me.
Thanks!
[Message sent by forum member 'kzri' (kzri)]

http://forums.java.net/jive/thread.jspa?messageID=284080