How to set connection timeout with OkHttp

后端 未结 11 842
一向
一向 2020-11-27 10:32

I am developing app using OkHttp library and my trouble is I cannot find how to set connection timeout and socket timeout.

OkHttpClient client = new OkHttpCl         


        
11条回答
  •  清酒与你
    2020-11-27 11:04

    You can set a call timeout to cover the entire cycle from resolving DNS, connecting, writing the request body, server processing, and reading the response body.

    val client = OkHttpClient().newBuilder().callTimeout(CALL_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES).build()
    

提交回复
热议问题