2

I got a client like this:

public enum RestClient {

INSTANCE;
private static final int CONNECTION_TIMEOUT = 10;
private static final int READ_TIMEOUT = 30;
private static final int WRITE_TIMEOUT = 30;
private final Rest restClient;

private RestClient() {
    restClient = new Retrofit.Builder()
            .baseUrl(App.getContext().getResources().getString(R.string.EP))
            .addConverterFactory(JacksonConverterFactory.create())
            .client(new okhttp3.OkHttpClient.Builder()
                    .connectTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
                    .readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
                    .writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
                    .build())
            .build()
            .create(Rest.class);
}

public Rest getRestClient() {return restClient;}

}

and i use this like this:

RestClient.INSTANCE.getRestClient().getAndroidConf().enqueue(new Callback<List<Config>>() {
        @Override
        public void onResponse(Call<List<Config>> call, Response<List<Config>> response) {
            //
        }

        @Override
        public void onFailure(Call<List<Config>> call, Throwable t) {
            //
        }
    });

I've recently updated to retrofit 2 and okhttp3, the problem is that i was expecting that when a timeout occures it enter onFailure callback, as the old retrofit did.

Any suggestions? Thanks

LinkOut
  • 273
  • 2
  • 4
  • 13
  • [http://stackoverflow.com/questions/29921667/retrofit-and-okhttpclient-catch-connection-timeout-in-failure-method](http://stackoverflow.com/questions/29921667/retrofit-and-okhttpclient-catch-connection-timeout-in-failure-method) – M D Jun 01 '16 at 15:27

0 Answers0