-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to obtain the default HttpHandler in order to only influence keepalive settings #1950
Comments
I now implemented it as follows, but I only set /// Apply default HTTP2 gRPC keep-alive settings. The time between keep-alive pings is ten seconds, and the timeout
/// per ping is five seconds, the default `HttpKeepAlivePingPolicy` is `HttpKeepAlivePingPolicy.WithActiveRequests`.
let withDefaultKeepAlive (channelOptions: GrpcChannelOptions) =
let handler = new System.Net.Http.SocketsHttpHandler ()
// Minimal value is 10s, lower values are automatically increased to 10s.
handler.KeepAlivePingDelay <- TimeSpan.FromSeconds 10
// Time to wait for a ping reply before the connection is closed. Applications should ensure keep-alive timeout
// is at least multiple times the round-trip time to allow for lost packets and TCP retransmits.
handler.KeepAlivePingTimeout <- TimeSpan.FromSeconds 5
// Only send pings when there are active RPCs (or streams).
handler.KeepAlivePingPolicy <- HttpKeepAlivePingPolicy.WithActiveRequests
// `EnableMultipleHttp2Connections` is also enabled by the default internal gRPC HttpHandler.
handler.EnableMultipleHttp2Connections <- true
channelOptions.HttpHandler <- handler
channelOptions.DisposeHttpClient <- true
channelOptions I would rather not have to depend on this manual copy of the default settings. |
HttpHandler doesn't have a good way to compose your settings with the default settings. What you're doing, creating a new SocketsHttpHandler and then setting everything on it, is the best solution. |
Thank you for the confirmation :). Should there be an option on the channel level to be able to set keep alive settings? Doing this via this http handler feels very 'low-level' to me. I also think that enabling HTTP keep alives would (should?) be very common. Especially because gRPC supports long lived streams and keep alives are the only way to timely detect certain connection failures. I also see this going wrong at my place of work, people often do not realize that enabling the keep alive settings is required. It is assumed that a channel already 'reliably' detects connection failures. Side question: using the |
There is a similar discussion about channel options at #1842. |
The problem is a lot of these APIs are only available on certain HttpHandler implementations. What should happen if the handler doesn't support keep alive? Throw an error? Silently ignore the setting? |
Channel options Does anyone know how/if this worked with the old
Some of them are predefined in that class some you can only set via a custom
How was this previously implemented? Do all options always work? Only as long as you do not change the default Default HttpHandler I understand that some of the options might not be applicable if the underlying My original question was if it is possible to obtain the default Then users could only overwrite the settings, on that default handler, which they actively want to change. |
Answering my own side question, I had a reference to the old |
Hello,
I want to enable HTTP/2 keep alive for a gRPC client. I believe that I should supply the relevant settings via the
GrpcChannelOptions.HttpHandler
property.My question is, how should I construct a default
HttpMessageHandler
, which normally happens here.I only want to influence the keepalive settings, the rest should be the gRPC defaults which are used internally.
Is there something I am missing here or should those default be exposed somehow?
The text was updated successfully, but these errors were encountered: