Hi,

On Tue, May 2, 2023 at 10:33 PM Adam Fine <[email protected]> wrote:
>
> Hi all, My use case is that  I need to  cancel a long running  database 
> execution if the client disconnects.
>
> Setting setMaxInactiveInterval in combination with   a HttpSessionListener  
> sessionDestroyed event  seems promising but the events only generate   on the 
> next  attempt to connect with the expired session.   I could probably 
> implement a thread which periodically checked every session but I'm wondering 
> if there are any common patterns for this use case.   I see AsyncContext 
> raised as an option but the listeners on the  AsyncContext    do not detect  
> if a client disconnects and leave me in the same place as using a 
> HttpSessionListener.
>

There is no pattern available for HTTP/1.1, because the server must
stop reading after the request (so it cannot read the -1 as the result
of the client closing), otherwise it is open to infinite buffering
attacks.
It can be done by the server returning a response with URIs that the
client can "poll" to check whether the request finished or "poll to
cancel".

In HTTP/2 the client may send a RST_STREAM so the server can detect it
and notify AsyncListener.onError(), so way easier, but only HTTP/2
specific.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to