HTTP/2 client and closed connections

2024-03-12 Thread Jonathan Amir
Hello,
I am building an HTTP/2 only client for running multiple requests in
parallel.
I understand that there is no connection pool internally, rather there is
one connection per host. For simplicity, let's say all my requests go to
the same host.

I have a situation where under stress there are some errors. It starts with
socket timeout (several threads in parallel), and after a while there is a
ConnectionClosedException.
I am not sure what is the flow of events that leads to this, and what is
the relationship between those errors. I also don't know if it is my client
or the server that closed the connection.

My initial question is, since there is only one connection maintained
internally, how does one recover from ConnectionClosedException? The
connection life-cycle is opaque to me - there is no pool, and no eviction
strategy, so no concept of creating a new connection. So what am I missing? Is
the httpClient object still usable after a ConnectionClosedException?

Somewhat related, I am looking at the sample here:
https://hc.apache.org/httpcomponents-client-5.3.x/migration-guide/migration-to-async-http2.html
What is the difference between the two socket timeout configurations, on
IOReactorConfig and ConnectionConfig? What is the time to live?

Thanks,
Jonathan


Re: Websocket client using ReactiveResponseConsumer and ReactiveEntityProducer

2024-03-12 Thread Oleg Kalnichevski
On Tue, 2024-03-12 at 10:32 -0400, Sneha Murganoor wrote:
> Hi,
> 
> I am writing a websocket client with APIs ReactiveResponseConsumer
> and
> ReactiveEntityProducer. Once the websocket server completes the
> handshake
> by upgrading connection and returning 101. We do get Http status code
> and
> headers after the handshake completes. But not Publisher.
> 
> So we get httpStatus and headers from
> https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L210
> But it returns if the status code is less 200.
> https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L229
> We want it to consume entity details so we get Publisher
> https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L249
> 
> Could you help figuring this out?
> 
> Thanks,
> Sneha


Sneha

HttpClient does not support Websockets protocol at the moment and
likely never will.

One can pretty much do with HTTP/2 all what Websockets can do.


Oleg

-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Websocket client using ReactiveResponseConsumer and ReactiveEntityProducer

2024-03-12 Thread Sneha Murganoor
Hi,

I am writing a websocket client with APIs ReactiveResponseConsumer and
ReactiveEntityProducer. Once the websocket server completes the handshake
by upgrading connection and returning 101. We do get Http status code and
headers after the handshake completes. But not Publisher.

So we get httpStatus and headers from
https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L210
But it returns if the status code is less 200.
https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L229
We want it to consume entity details so we get Publisher
https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java#L249

Could you help figuring this out?

Thanks,
Sneha