users@glassfish.java.net

Re: CometHandler#onInterrupt() incompatibility

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 02 Jun 2008 16:54:32 -0600

Salut,

Leonid Mokrushin wrote:
> Hi,
>
>> Hum...which OS are you using on the server side and which browser?
> I've just tested with Firefox on MacOS and v3 (not tp2, but current
> release) on the Ubuntu. I've also tested with ur2 b4 on the same setup
> and it works.
>
> I have retested the following code on both Windows XP(jdk1.6.0_06) and
> Ubuntu 7.10(jdk1.6.0_03) server on v2ur2b04 and v3tp2 and none of them
> worked (I never get "onInterrupt" message). I'm using Firefox3b5 on
> Windows as a browser.

OK let me try that. I'm on the road this week (doing Comet talks :-))
but as soon as I've time, I will test with you configuration.

Thanks!

-- Jeanfrancois


>
>
> import java.io.IOException;
> import java.io.PrintWriter;
>
> import javax.servlet.ServletConfig;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
> import com.sun.enterprise.web.connector.grizzly.comet.CometContext;
> import com.sun.enterprise.web.connector.grizzly.comet.CometEngine;
> import com.sun.enterprise.web.connector.grizzly.comet.CometEvent;
> import com.sun.enterprise.web.connector.grizzly.comet.CometHandler;
>
>
> public class CometTest extends HttpServlet {
>
> private String contextPath;
>
> public void init(ServletConfig config) throws ServletException {
> super.init(config);
> contextPath = config.getServletContext().getContextPath() +
> "/comet";
> CometEngine cometEngine = CometEngine.getEngine();
> CometContext context = cometEngine.register(contextPath);
> context.setExpirationDelay(-1);
> context.setBlockingNotification(true);
> }
>
> protected void doGet(final HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> CometEngine cometEngine = CometEngine.getEngine();
> CometContext cometContext =
> cometEngine.getCometContext(contextPath);
> response.setContentType("text/plain");
> response.getWriter().flush();
> TerminalHandler handler = new TerminalHandler();
> handler.attach(response.getWriter());
> cometContext.addCometHandler(handler);
> }
>
> class TerminalHandler implements CometHandler<PrintWriter> {
>
> private PrintWriter writer;
>
> public void attach(PrintWriter writer) {
> this.writer = writer;
> }
>
> public void onEvent(CometEvent event) throws IOException {
> System.out.println("onEvent");
> }
>
> public void onInitialize(CometEvent event) throws IOException {
> System.out.println("onInitialize");
> }
>
> public void onInterrupt(CometEvent event) throws IOException {
> System.out.println("onInterrupt");
> }
>
> public void onTerminate(CometEvent event) throws IOException {
> System.out.println("onTerminate");
> }
>
> }
>
> }
>
> -----Original Message-----
> From: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
> Sent: Friday, May 30, 2008 17:14
> To: users_at_glassfish.dev.java.net
> Subject: Re: CometHandler#onInterrupt() incompatibility
>
> Salut,
>
> Leonid Mokrushin wrote:
>> My application is dependent on the fact of detecting the loss of the
>> connection during the long-polling or streaming comet request. As far
>> as I understand the onInterrupt() method of the CometHandler is
>> supposed to be called in such cases.
>
> Indeed.
>
> And it is very easy to test it by just pressing
>> the stop button in the browser. I noticed that in Glassfish v2ur2 as
>> well as v3tp2 the method is not called however in v2.1b35 it is.
>
> Hum...which OS are you using on the server side and which browser? I've
> just tested with Firefox on MacOS and v3 (not tp2, but current release)
> on the Ubuntu. I've also tested with ur2 b4 on the same setup and it
> works.
>
> I guess
>> not handling of this event may be used for DoS attacks as well as
>> cause problems for applications like mine. Is it supposed to be fixed
>> in v3 and/or v2 later on?
>
> Can you send me a test case that reproduce the problem?
>
> Thanks!
>
> -- Jeanfrancois
>
>
>>
>> Thanx
>> /Leonid Mokrushin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>