Hello, We are using Apache HttpClient 5.2.1 to connect to potentially different servers, and for each of them, we can have a mix of "classic" HTTP requests and long connections to receive Server-Sent Events. In some cases, we have to cancel those long requests and reopen them later.
Today we use a single client instance for all requests, that is configured like this <https://github.com/SonarSource/sonarlint-core/blob/9.2.0.74516/http/src/main/java/org/sonarsource/sonarlint/core/http/HttpClientProvider.java#L91>. SSE connections are opened here <https://github.com/SonarSource/sonarlint-core/blob/9.2.0.74516/http/src/main/java/org/sonarsource/sonarlint/core/http/ApacheHttpClientAdapter.java#L105> and canceled here <https://github.com/SonarSource/sonarlint-core/blob/9.2.0.74516/http/src/main/java/org/sonarsource/sonarlint/core/http/ApacheHttpClientAdapter.java#L250> . We recently noticed that after canceling SSE connections, we were still receiving events from the server. We made some assumptions: * canceling the Future returned by CloseableAsyncHttpClient.execute() does not close the connection, so we keep receiving events * This might be caused by the connection manager, who retains the connection Are our assumptions right? Can we configure the connection manager to close and not reuse those connections used for SSE? Or would we have to use separate clients? One thing that we noticed when we investigated is that in rare cases, the connection would close and wouldn't be reused. In this scenario, we can see an InterruptedException in the logs, triggered from this line <https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java#L137>. Is there something we are not doing correctly? Thanks in advance, Damien Urruty | Sonar Developer @ SonarLint https://sonarsource.com Are you using SonarLint <https://www.sonarlint.org> in your IDE?