I referred this link but I can\'t seem to implement for mine
I am using
compile \'com.squareup.retrofit2:retrofit:2.0
try below code, it sét timeout
is 20 seconds and readTimeout
is 30 seconds
private OkHttpClient getRequestHeader() {
OkHttpClient httpClient = new OkHttpClient();
httpClient.setConnectTimeout(20, TimeUnit.SECONDS);
httpClient.setReadTimeout(30, TimeUnit.SECONDS);
return httpClient;
}
Then
public class ApiClient {
public static final String BASE_URL = Constants.BaseURL;
private static Retrofit retrofit = null;
public static Retrofit getClient() {
if (retrofit==null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(getRequestHeader())
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}