Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Request processing termination on client disconnect

Hello.

Is there a way to stop request processing when client (browser)
prematurely closes connection?
We have a very resource consuming queries to the backend and want to
cancel them when the user navigates using the links from the part of
the page he already received (several ajax requests in parallel) or
just closes the browser.

Servlet-api does not provide API for such a notification so that
should be something jetty-specific i guess. I already tried
NetworkTrafficListener with NetworkTrafficSelectChannelConnector but
the listener's closed() method is only invoked after the servlet have
handled the request even if disconnect happened much earlier. I guess
this is the expected behaviour and i guess the reason for it is that
selector thead stops listening to events on the socket channel while
the request is being handled (so disconnect is not even detected). As
far as i understand this is the best solution to handle HTTP
keep-alive and thats why it is implemented that way. But we don't need
keep-alive because we use nginx in front of Jetty.

Maybe there is something i'm missing? I hope a simple solution exists.

We use Jetty 7.5.1 in OSGi container.


Back to the top