|[jetty-users] How to check if the client dropped the connection|
Hi, I'm working on the development of an open source application, GeoServer, implementing the Web Map Service specification. The specification allows a client to request maps using simple GET requests like: http://sigma.openplans.org:8080/geoserver/wms?WIDTH=431&SRS=EPSG%3A4326&LAYERS=tiger-ny&HEIGHT=550&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=-74.01697805908182,40.69808217724622,-73.99567744140603,40.72526393994153 By spec we're forced to use a plain request and response approach, but we're experiencing a problem with clients making lots of request as the user zooms/pans around: basically a request is made, but the user keeps on moving, the client drops the request and makes another. Unfortunately the older requirest is still running, drawing a map takes time and a lot of memory, for example the above request, which is a small one btw, allocates a BufferedImage of 700KB. The memory is consumed up until the image is encoded out to the stream, which is also the moment we finally figure out the client dropped the connection (since writing to the servlet output stream fails). This is very sub-optimal. Servers like Apache with cgi do kill the cgi process the moment the connection is dropped, significantly reducing the server load both in terms of CPU and memory consumption. Is there any way to check if the client connection is still open using only the standard servlet API? If not, is there any J2EE server specific approach that might work instead? I've tried already to monitor the request input stream in the hopes that a dropped connection would cause any operation against it to throw an IOException, but that does not happen. The output side is not helpful either, as I can start writing only when the image is fully drawn. As I said above the WMS is an international standard so I cannot touch neither the protocol, and of course I have no control over what the clients do either. If there is no solution that can be applied at the general servlet api level, do you know of any Jetty specific approach one could use? e.g., casting the HttpServletResponse to some Jetty specific class and get some connection information status there. I've looked a bit but did not find anything. Cheers Andrea -- Andrea Aime OpenGeo - http://opengeo.org Expert service straight from the developers.
Back to the top