Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 12.1 ResourceHandler: how to know if client closed HTTP connection?

I replied on StackOverflow:
https://stackoverflow.com/questions/79979650/jetty-12-1-resourcehandler-how-to-know-if-client-closed-http-connection

On Mon, Jul 13, 2026 at 12:09 PM Michał Niklas via jetty-users
<jetty-users@xxxxxxxxxxx> wrote:
>
> Hi,
>
> My application uses Jetty 12.1 and extends ResourceHandler to serve some
> types of data from database.
>
> Unfortunately some queries are very long: they create big PDF, XLS, or
> CSV files and sometimes client closes browser, or Kubernetes monitor
> resends query. I wanted to know if the client is still connected. I
> tried technique like:
>
> public boolean handle(Request request, Response response, Callback
> callback){
>      request.addFailureListener(failure -> {
>          log.error("Failure during serving " + request.getHttpURI() + "
> " + failure.toString() + " " + getState());
>      });
>      ...
> }
>
> My test query last few minutes so I can close browser during this
> period. Every long lasting query after 30 seconds writes to log:
>
> ... java.util.concurrent.TimeoutException: Idle timeout expired:
> 30000/30000 ms STARTED
>
> The query is completed regardless if I close browser (HTTP 1.1 by Chrome
> or curl) or wait for whole response. If I close browser or Ctrl-C for
> curl, there is no info that client closed connection.
>
> I would like to know if client closed connection to simply stop querying
> database and stop creating output. How can I do it?
>
> PS I have asked this question also on StackOverflow:
> https://stackoverflow.com/questions/79979650/jetty-12-1-resourcehandler-how-to-know-if-client-closed-http-connection
>
>
> --
> Best regards,
> Michal Niklas
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users



-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


Back to the top