Retrofit2 SSLHandshakeException

460 views Asked by At

I use Retrofit2. Requests are no execute after adding on server side SSL. The method onFailure get next Throwable - javax.net.ssl.SSLHandshakeException: Connection closed by peer.

Initialization Retrofit:

Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(InterfaceAPI.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
1

There are 1 answers

0
Muhammad Saad Rafique On
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
clientBuilder.connectTimeout(60, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).writeTimeout(60, TimeUnit.SECONDS);

client = clientBuilder.build();

Then use this client for retrofit