I am using retrofit and it works fine, but sometimes it does not get the connection and throws an exception of type SocketException, here are the configurations I use:
Version:
` 'com.squareup.okhttp3: okhttp: 3.5.0'
'com.squareup.retrofit2: retrofit: 2.1.0'`
OkHttpClient with readtimeout, connecttimeout and writetimeout, and Retrofit instance:
`...OkHttpClient okHttpClient = new OkHttpClient.Builder ()
.readTimeout (50, TimeUnit.SECONDS)
.connectTimeout (50, TimeUnit.SECONDS)
.writeTimeout (50, TimeUnit.SECONDS)
Retrofit retrofit = new Retrofit.Builder ()
.baseUrl ("endpoint")
.addConverterFactory (GsonConverterFactory.create ())
.client (okHttpClient) .build ();...`
This configuration I use as singleton pattern.