users@grizzly.java.net

Re: Problem with Grizzly/Comet on Glassfish 3.1.2

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Wed, 20 Jun 2012 12:00:07 +0200

Hi Enrique,

can you pls. attach the GF server.log file taken after this problem occurs?

Thanks.

WBR,
Alexey.

On 06/19/2012 06:25 PM, Enrique Ubinas wrote:
> So I'm attempting to set up http long polling with Grizzly Comet on
> Glassfish 3.1.2. I've enabled Comet on my Glassfish server and for
> whatever reason its still not working. When I make a calls to
> cometContext.notify(obj), the CometEventHandler doesn't receive any
> events. On top of that, I also noticed that the addCometHandler method
> doesn't suspend the connection and returns immediately. Wireshark
> tells me that I get a response from the server with a content length
> of zero. Any help with this is greatly appreciated. Below is the
> relevant sections of my code. Thank you.
>
> This code is found in the doGet method of my HttpServlet sub class.
>
> [code]
> final CometContext<?> cometContext =
> CometEngine.getEngine().register(Constant.COMPANY_LOCATIONS_TOPIC);
> final CompanyLocationHandler handler = new CompanyLocationHandler();
>
> handler.attach(response);
> cometContext.addCometHandler(handler);
> [/code]
>
> This code is found in the service method of another HttpServlet sub class.
>
> [code]
> final CometContext<?> cometContext =
> CometEngine.getEngine().register(Constant.COMPANY_LOCATIONS_TOPIC);
> final Location companyLocation = new Location(locationId, address,
> city, state, zipCode, country);
>
> cometContext.notify(companyLocation);
> [/code]
>
> And this my implementation of the onEvent method in
> CompanyLocationHandler.
>
> [code]
> public void onEvent(final CometEvent event) throws IOException
> {
> if (event.getType() == CometEvent.NOTIFY)
> {
> final Location companyLocation = (Location)event.attachment();
> final PrintWriter printWriter = this.response.getWriter();
>
> try
> {
> this.response.setContentType("application/json");
>
> printWriter.write(companyLocation.toJson());
> printWriter.flush();
> }
> finally
> {
> printWriter.close();
> }
>
> event.getCometContext().resumeCometHandler(this);
> }
> }
> [/code]
>
>