These are chat archives for ReactiveX/RxJava

16th
Feb 2016
Vasilis Charalampakis
@charbgr
Feb 16 2016 10:19
Hi anyone here using Retrofit 1.9?
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 10:35
@charbgr yes
Vasilis Charalampakis
@charbgr
Feb 16 2016 10:35
nice
do you know why Retrofit 1.9 swallows error like SocketTimeoutException and the observable’s onError method is not called?
basically Network Errors
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 10:41
@charbgr Actually, i've never got this error...
Vasilis Charalampakis
@charbgr
Feb 16 2016 10:41
any RetrofitError is not passed to onError
weird
you can test it if you close all network connections and make a call to your server
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 10:45

Do you apply OkClient in your RestAdapter?
Like this:

@Provides
    @Singleton
    public RestAdapter provideRestAdapter(@Named("apiOkClient") Client client, DBQErrorHandler errorHandler){
        RestAdapter API = new RestAdapter.Builder()
                .setEndpoint(NEW_PRODUCTION_API_URL)
                .setErrorHandler(errorHandler)
                .setClient(client)        // <<<<
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build();
        return API;
    }

Where Client client is

@Singleton
    @Provides
    @Named("apiOkClient")
    public Client provideClient(){
        return new OkClient(createOkHttpClient());
    }

private static OkHttpClient createOkHttpClient(){
        OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(5, TimeUnit.MINUTES);
    client.setReadTimeout(5, TimeUnit.MINUTES);
        return client;
    }
Vasilis Charalampakis
@charbgr
Feb 16 2016 10:48
yes
but i have smaller timeouts
20 seconds
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 10:58
try to increase it
but I think it isn't the problem
Vasilis Charalampakis
@charbgr
Feb 16 2016 10:59
the problem is not to increase it
it’s retrofit design
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 11:01

Also, try this client:

private static OkHttpClient getUnsafeOkHttpClient() {
        try {
            // Create a trust manager that does not validate certificate chains
            final TrustManager[] trustAllCerts = new TrustManager[] {
                    new X509TrustManager() {
                        @Override
                        public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                        }

                        @Override
                        public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                        }

                        @Override
                        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                            return null;
                        }
                    }
            };

            // Install the all-trusting trust manager
            final SSLContext sslContext = SSLContext.getInstance("SSL");
            sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
            // Create an ssl socket factory with our all-trusting manager
            final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();

            OkHttpClient okHttpClient = new OkHttpClient();
            okHttpClient.setSslSocketFactory(sslSocketFactory);
            okHttpClient.setHostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            });

            return okHttpClient;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

I'm not sure it will help you, but try it please

Vasilis Charalampakis
@charbgr
Feb 16 2016 11:01
trust any certification is not safe
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 11:02
Yes
Vasilis Charalampakis
@charbgr
Feb 16 2016 11:03
increasing the timeout is not solving the problem
Alexander Garmash
@AlexanderGarmash
Feb 16 2016 11:03
With this exception I think you have the perfect safiety :smile:
dwursteisen
@dwursteisen
Feb 16 2016 15:19
Anyone played with the RxJavaSchedulersHook plugin. With a Executor Service as a scheduler, the "onSchedule" method hook is not called. I don't know if it's expected...
(my goal is to progragate some MDC key thought my Observable) => http://blog.mabn.pl/2014/11/rxjava-logback-and-mdc-threadlocal.html