-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to config the Timeout #641
Comments
Retrofit does not support setting timeouts for two reasons:
If you are using OkHttp you can set timeouts on the builder.setClient(new OkClient(client)) For the JDK's public final class MyUrlConnectionClient extends UrlConnectionClient {
@Override protected HttpUrlConnection openConnection(Request request) {
HttpUrlConnection connection = super.openConnection(request);
connection.setConnectTimeout(15 * 1000);
connection.setReadTimeout(30 * 1000);
return connection;
}
} and then passing an instance to the builder.setClient(new MyUrlConnectionClient()); |
I am getting timeout error in logcat when i used retofit on my code... Could you please suggest me a solution. |
Hey, @JakeWharton! I'm facing some timeout issues in my application. My OkClient object is set like this: OkHttpClient client = new OkHttpClient(); In my Builder I'm setting the client as this okClient I just described (it works fine). My idea is to catch timeout situations/exceptions when they happen. I want to show my user the timeout happened and he/she could try again later. Am I missing something? Is there any other documentation I can follow to fix this? Thank you. |
Hi, I have a problem on retrofit about to config the timeout with retrofit. My code like this:
sBaseUrl = Configs.getString(Configs.BASE_URL);
how to do it?? Is there a way to config the timeout no matter which kind of way to send a request such as okhttp or other??
The text was updated successfully, but these errors were encountered: