-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow enabling HTTP/2 PING and disabling read timeout for streams #13
Comments
@kohenkatz - This seems like a reasonable request. Would it work for you to just change the constructor to: class ConnectOkHttpClient @JvmOverloads constructor(
private val unaryClient: OkHttpClient = OkHttpClient(),
private val streamClient: OkHttpClient = unaryClient,
) : HTTPClientInterface { Then in |
@pkwarren Yes, that sounds like it would do what I want. |
pkwarren
added a commit
that referenced
this issue
Oct 10, 2023
Streaming calls often require longer timeouts (for long lived streams) and enabling pings (to keep the underlying connection alive). Update ConnectOkHttpClient to take a second OkHttpClient argument to the constructor to be used for streaming calls. Fixes #13.
pkwarren
added a commit
that referenced
this issue
Oct 11, 2023
Streaming calls often require longer timeouts (for long lived streams) and enabling pings (to keep the underlying connection alive). Update ConnectOkHttpClient to take a second OkHttpClient argument to the constructor to be used for streaming calls. Fixes #13.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The default okhttp
readTimeout
is 10 seconds, which is too short for many uses of streaming RPCs. As an alternative way to detect broken connections, HTTP/2 provides aPING
mechanism. okhttp has pings disabled by default, but they can be enabled by callingpingInterval()
on the builder. Streaming calls can setreadTimeout
to0
to disable the read timeout and rely only on the ping timeout, if desired.The problem is that there is not an easy way to change the okhttp settings for unary vs. streaming calls, and we still want to have a read timeout for the unary calls.
I thought it would be easiest to fix this by extending
ConnectOkHttpClient
to customize theclient
object and then call the parent method using the customized client, butConnectOkHttpClient
would need to beopen
instead offinal
to allow this.I ended up doing this, which feels like a nasty hack:
The text was updated successfully, but these errors were encountered: