java.net.SocketTimeoutException: timeout

前端 未结 6 906
余生分开走
余生分开走 2021-02-03 18:27

With OkHttp library, application is facing following SocketTimeoutException issue. If request size is less, then it is working fine(Less than 1MB). I a

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-03 18:44

    I solved that problem increasing writeTimeout().

    Try:

    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.connectTimeout(5, TimeUnit.MINUTES) // connect timeout
    .writeTimeout(5, TimeUnit.MINUTES) // write timeout
    .readTimeout(5, TimeUnit.MINUTES); // read timeout
    
    okHttpClient = builder.build();
    

提交回复
热议问题