okhttp3.OkHttpClient-到any_host的连接已泄漏。您是否忘了关闭响应正文?

时间:2019-02-13 16:57:24

标签: okhttp3

在Kotlin的项目中,我使用okhttp3

这里是连接到远程主机的示例:

    import okhttp3.*
    import okhttp3.logging.HttpLoggingInterceptor

var оkHttpClient = OkHttpClient()        оkHttpClient.newCall(requestNegotiate).enqueue(object : Callback {
             override fun onResponse(call: Call, response: Response) {
                  ...
             }}

并且工作正常。

但是几分钟后,我收到很多下一条消息:

  2019-02-13 18:39:39,197 675399 [OkHttp ConnectionPool] WARN  okhttp3.OkHttpClient - A connection to any_host_com was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);

0 个答案:

没有答案