You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by aaime74 <an...@gmail.com> on 2007/07/08 12:06:27 UTC

Any way to check the client abruptly close the connection?

Hi,
I'm fighting a relatively nasty issue. I've implemented a WMS service (Web
Map Server), which basically
returns a geographic map in response to a request stating which data to use,
which area to display, which style to apply to the map, and so on.

The main trouble is that building the map can take anywhere from 100ms to
minutes, depending on
how much data is needed, and during the map building time the output stream
is not touched (the map is drawn on a buffered image, which is encoded to
png/gif/jpeg only when completely drawn).
It happens quite often that the client closes the connection because the map
is taking too much time to be generated, and I would like to be informed
about this right away to avoid wasting precious resources.

Is there any way to know?
Cheers
Andrea

-- 
View this message in context: http://www.nabble.com/Any-way-to-check-the-client-abruptly-close-the-connection--tf4043946.html#a11487168
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any way to check the client abruptly close the connection?

Posted by Bill Barker <wb...@wilshire.com>.
"aaime74" <an...@gmail.com> wrote in message 
news:11496790.post@talk.nabble.com...
>
>
>
> Johnny Kewl wrote:
>>
>> This is an interesting question, and I'm going to "guess"...
>> If you in a JSP page, I dont think the error can be trapped.
>>
>> If you in a servlet, yes I think a try catch will detect it, but only if
>> you
>> actually write something.
>>
>
> Which I can't do. The WMS is an international standard, I cannot bend it
> to my will, since the point of the application is to be fully conformant 
> to
> it.
>
> This is a pity, I mean, the webapp container should have a way to check
> the socket is gone bye bye without writing on it, no?
>

No, the Servlet-API doesn't have a mechanism to asynchronously notify a 
Servlet about much of anything (since all communication is required to take 
place on one thread).

As Johnny mentioned before, you might be able to do this in Tomcat 6 by 
using the AIO (aka Comet) features.  With the standard Servlet interface, 
Tomcat won't even look at the Socket until you decide to do a read/write, so 
will have no idea that the Socket is dead until then.  Google on things like 
"Comet" and "Ajax", and ask your doctor if it might be right for you ;-).

> Cheers
> Andrea
> -- 
> View this message in context: 
> http://www.nabble.com/Any-way-to-check-the-client-abruptly-close-the-connection--tf4043946.html#a11496790
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any way to check the client abruptly close the connection?

Posted by aaime74 <an...@gmail.com>.


Johnny Kewl wrote:
> 
> This is an interesting question, and I'm going to "guess"...
> If you in a JSP page, I dont think the error can be trapped.
> 
> If you in a servlet, yes I think a try catch will detect it, but only if
> you 
> actually write something.
> 

Which I can't do. The WMS is an international standard, I cannot bend it
to my will, since the point of the application is to be fully conformant to
it.

This is a pity, I mean, the webapp container should have a way to check
the socket is gone bye bye without writing on it, no?

Cheers
Andrea
-- 
View this message in context: http://www.nabble.com/Any-way-to-check-the-client-abruptly-close-the-connection--tf4043946.html#a11496790
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Any way to check the client abruptly close the connection?

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
This is an interesting question, and I'm going to "guess"...
If you in a JSP page, I dont think the error can be trapped.

If you in a servlet, yes I think a try catch will detect it, but only if you 
actually write something.

I think the generic problem is that you cant just leave the browser standing 
there doing sweat nothing.... and I appreciate the problem, its tricky.

Think you going to have to resort to AJAX or something like that.
Dont know anything about WMS, but I imagine it collects images and assembles 
the overlays.
If perhaps you could send the user a base overlay, while it was been 
assembled, that may keep them interested, then when its ready, AJAX kills 
the base image and replaced it with the full assembly.... something like 
that.

I think the problem comes down to sending the user something, while its 
being assembled.

good luck....




----- Original Message ----- 
From: "aaime74" <an...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Sunday, July 08, 2007 12:06 PM
Subject: Any way to check the client abruptly close the connection?


>
> Hi,
> I'm fighting a relatively nasty issue. I've implemented a WMS service (Web
> Map Server), which basically
> returns a geographic map in response to a request stating which data to 
> use,
> which area to display, which style to apply to the map, and so on.
>
> The main trouble is that building the map can take anywhere from 100ms to
> minutes, depending on
> how much data is needed, and during the map building time the output 
> stream
> is not touched (the map is drawn on a buffered image, which is encoded to
> png/gif/jpeg only when completely drawn).
> It happens quite often that the client closes the connection because the 
> map
> is taking too much time to be generated, and I would like to be informed
> about this right away to avoid wasting precious resources.
>
> Is there any way to know?
> Cheers
> Andrea
>
> -- 
> View this message in context: 
> http://www.nabble.com/Any-way-to-check-the-client-abruptly-close-the-connection--tf4043946.html#a11487168
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org