okhttp 支持 http2 中的连接池

标签 okhttp

okhttp 是否支持 http2 客户端的连接池? 官方文档https://square.github.io/okhttp/说这个 “连接池减少了请求延迟(如果 HTTP/2 不可用)”。

okhttp 是否有任何方法可以根据 rfc https://www.rfc-editor.org/rfc/rfc7540#section-5.1.2 配置连接上允许的最大并发流? okhttp http2 客户端发送的最大并发流的默认值是多少?当达到最大并发流阈值时,接收方发送拒绝流错误时会发生什么?是重试还是请求失败?

最佳答案

Does okhttp has any way to configure the max concurrent streams allowed on a connection as per rfc https://www.rfc-editor.org/rfc/rfc7540#section-5.1.2 ?

目前没有。

What is the default value for max concurrent streams sent by okhttp http2 client ?

这是荣幸。

What happens when receiver sends refused stream error when max concurrent streams threshold is met ? Is it retried or request fails ?

OkHttp 将使请求一直失败到应用程序。不过,您不应该期望看到这一点,因为 OkHttp 遵守最大并发流限制。

请注意,连接创建很活跃。这个限制可能只有在 OkHttp 创建了多个流之后才知道。在这种情况下,服务器应该允许这些流。

关于okhttp 支持 http2 中的连接池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62529900/

相关文章:

java - 如何在Okhttp中使用Socks5代理来启动http请求

android - Kotlin中如何使用OKHTTP发送post请求?

http - 为什么 OkHttp 在设置 If-Modified-Since header 时会像对待 Last-Modified header 一样对待 Date header ?

android 基本认证 okhttpclient

java - 如何从 okhttp 的缓存中删除 url?

java - Android 从 Okhttp onResponse 函数中提取字符串

android - 使用 Realm + Okhttp 时无法获取崩溃的确切原因

android - 来自 HttpURLConnection 的 OkHttpClient 连接泄漏警告

android - Retrofit 1.9 RestAdapter 无法在 Android Studio 中解析 Symbol

java - 是否可以使用 Okhttp 从文件系统访问本地文件