【问题标题】:Handling HTTP/2 GOAWAY in okhttp4在 okhttp4 中处理 HTTP/2 GOAWAY
【发布时间】:2021-03-21 08:15:29
【问题描述】:

我正在使用okhttp4 4.9.0 向 APNs Http/2 服务器发送推送通知。 对APNs 的调用是同步的。

Apple 的在线文档有以下内容:

如果 APNs 决定终止已建立的 HTTP/2 连接,它 发送 GOAWAY 帧

如何在 okhttp4 中处理这个问题?

try {
    okHttpClient.newCall(request).execute().use { response -> println(response.code)  }
} catch(ioException: IOException) {
    //Is this the place to handle GOAWAY?          
} 

【问题讨论】:

    标签: okhttp http2


    【解决方案1】:

    在实践中,您永远不必担心使用 OkHttp 的 GOAWAY 帧。如果收到一个,它只会在下一个请求时创建一个新连接。

    【讨论】:

    • 值得注意的是,我们删除了 APNs 发送的有用的特定错误消息,因为 // TODO: log the debugData
    • 谢谢@jesse-wilson。它是否记录在某处?请把它的链接发给我。
    猜你喜欢
    • 1970-01-01
    • 2017-05-26
    • 1970-01-01
    • 2021-07-03
    • 2021-07-05
    • 2017-12-16
    • 1970-01-01
    • 2021-08-25
    • 2015-09-10
    相关资源
    最近更新 更多