I use the library Retrofit, when the Internet is slow, then when sending photos to the server, a time out error occurs. I tried this way to increase the wait time, but still the default wait time is 10 seconds. Please help me what I am doing wrong.
Here is my code:
public class RestClient { private UploadService uploadService; private String URL ="http://10.0.2.2:7899/api/"; public RestClient(){ Gson localGson = new GsonBuilder().create(); final OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(60, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(60, TimeUnit.SECONDS); this.uploadService = ((UploadService) new RestAdapter.Builder() .setEndpoint(URL) .setClient(new OkClient(okHttpClient)) .setEndpoint(URL) .setConverter(new GsonConverter(localGson)) .setRequestInterceptor(new RequestInterceptor() { public void intercept(RequestFacade requestFacade) { if (URL.contains("10.0.2.2")) { requestFacade.addHeader("Host", "localhost"); } } }) .build().create(UploadService.class)); } public UploadService getService() { Log.e("ServiceName", this.uploadService.toString()); return this.uploadService; } }