Platform/Android
[Okhttp] timeout 설정
개랭갱깽스타
2021. 10. 8. 18:12
Connect Timeout
Read Timeout
Write Timeout
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(VansBuildConfig.DEBUGGABLE ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
builder.addInterceptor(loggingInterceptor);
builder.connectTimeout(60, TimeUnit.SECONDS);
builder.readTimeout(90, TimeUnit.SECONDS); //받는(응답기다림)
builder.writeTimeout(60, TimeUnit.SECONDS); //보내는거(요청시간)
if (interceptor != null) {
builder.addInterceptor(interceptor);
}
참고.
https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/read-timeout/
https://effectivesquid.tistory.com/entry/Timeout%EC%97%90-%EA%B4%80%ED%95%9C-%EC%A0%95%EB%A6%AC
반응형