I was wondering how many seconds should I set to my retrofit client.
- How many seconds should I use as default timeout?
 - What is the default timeout for OkHttp/Retrofit, should we let default values?
 
I was wondering how many seconds should I set to my retrofit client.
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                Source:
OkHttpClient defaultClient() {   
    OkHttpClient client = new OkHttpClient();
    client.setConnectTimeout(15, TimeUnit.SECONDS);
    client.setReadTimeout(15, TimeUnit.SECONDS);
    client.setWriteTimeout(15, TimeUnit.SECONDS);
    return client;
}
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                You can use
OkHttpClient okHttpClient = new OkHttpClient.Builder()  
        .connectTimeout(1, TimeUnit.MINUTES)
        .readTimeout(30, TimeUnit.SECONDS)
        .writeTimeout(15, TimeUnit.SECONDS)
        .build();
Retrofit.Builder builder = new Retrofit.Builder()  
        .baseUrl("http://10.0.2.2:3000/")
        .client(okHttpClient)
        .addConverterFactory(GsonConverterFactory.create());
for more details go to: https://futurestud.io/tutorials/retrofit-2-customize-network-timeouts
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                I'am using it like this in my RetrofitApiClient . okhttp version 3.4.1
public class RetrofitApiClient {
         private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
                .connectTimeout(15, TimeUnit.SECONDS)
                .readTimeout(15L, TimeUnit.SECONDS)
                .writeTimeout(15L, TimeUnit.SECONDS);
        public  void someMethod() {
            OkHttpClient client = httpClient.build();
        }
}
                        
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/OkHttpClient.kt#L471
https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/OkHttpClient.kt#L203
internal var connectTimeout = 10_000
internal var readTimeout = 10_000
internal var writeTimeout = 10_000
                        
Retrofit code snippet: (if you don't provide an OkHttpClient):
OkHttp code snippet:
They are using different values. For example for feedback related they use:
They are using Volley and you can take a look at some timeouts there as well. And yes they look short.
In a different http client they give you some clues about what they consider is a short and reasonable short timeout.