Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] HttpClient stops occasionally

Hi Simone,

Oct 12, 2023, 11:58 by sbordet@xxxxxxxxxxx:

> Hi,
>
> Use this:
> https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-arch-bean-listener-lifecycle
>
> Add the listener to HttpClient (not Server as in the example), and in
> the listener you can create/throw/log an exception so you will have
> the stack trace of what code is calling stop().
>
> Let us know if it worked and what was it (may be useful to others).
>

Thanks, that helped us to trace down the root issue. We found that it was stopped from one of our own libs that is not direct part of our codebase. So it was our own fault!

We decided to keep the following snippet in our codebase to prevent that the httpclient is stopped in the future:

httpClient.addEventListener(new LifeCycle.Listener() {
    @Override
    public void lifeCycleStopped(LifeCycle event) {
        // prevent stopping of http client as it is used in various places
        var e = new RuntimeException("Don't stop me know!");
        try {
            httpClient.start();
        } catch (Exception ex) {
            // handle ex        }
        throw e;
    }
});

Thanks again and have a nice weekend!

Best,
Matthias


Back to the top