OkHttp is behaving as it should. A SocketTimeoutException
happens when the server takes longer to respond than what the client is willing to wait, and it just gives up. There is a default read timeout of 10 seconds since OkHttp 2.5 (and including the new 3.0), which would explain why you're getting the exception after 15 seconds.
You can set your own timeouts to allow your server ample time to respond:
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(20, TimeUnit.SECONDS); // connect timeout
client.setReadTimeout(20, TimeUnit.SECONDS); // socket timeout
Note that this doesn't handle the exception, it will still be thrown if the client doesn't receive a response in x
seconds now. I would make sure to actually catch the exception. This would be an appropriate place to have your retry logic.
Since you're using RxJava with Retrofit, you could just add retry/retryWhen
to your chain to catch and handle SocketTimeoutException
errors, and maybe even mix in exponential backoff.