com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted:
I found the problem after hours of searching through the Internet and project code:
Inside the project I have a class named JsonToPOJORequest<T>
, that extends the Volley class JsonRequest<T>
.
This is the class that actually makes the request for every method on the server.
After analysing the code a little bit, I found a method call inside the constructor, as follows:
setRetryPolicy(new DefaultRetryPolicy(3*DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 0, 0));
where DefaultRetryPolicy.DEFAULT_TIMEOUT_MS
is set as 2500 ms.
Because the POST request had a lot of data, it takes more time to send the request and receive the response back from server.
It seems that Volley didn't wait enough for the response to come and throws a TimeoutError. So, the request was made, everything goes well on the server, but the client(Android) does not wait for the server and gets an error.
The solution was to set the Timeout parameter to be higher or 0, like this:
setRetryPolicy(new DefaultRetryPolicy(5*DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 0, 0));
setRetryPolicy(new DefaultRetryPolicy(0, 0, 0));
The two questions that remain are:
1) Why does it take so long to make the request? -> 3*2500 = 7500ms is quite a lot of time(over 7 seconds) to make a request. And this is not a server problem, since on iOS it works just fine.
2) Why does the VolleyError look like this?
com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted:
Should be TimeoutError and not NoConnectionError.
You can find more information about this bug here, were I also deduced the solution: Android Volley double post when have slow request
https://groups.google.com/forum/#!topic/volley-users/8PE9dBbD6iA