Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley long HTTPS Request never responsed

I've created a volley request to receive HTTPS backend.

RequestQueue queue = Volley.newRequestQueue(uiCallback.getContext(),
    new SSLVerification().getHurlStack(uiCallback.getContext()));

JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET,
    requestUrl, null, new Response.Listener<JSONObject>() {
    ...
}
req.setRetryPolicy(new DefaultRetryPolicy(3_600_000, 0, 0));

queue.add(req);

In the manifest, I have added the Internet permission as follows:

<uses-permission android:name="android.permission.INTERNET" />

Everything works fine with requests that take only a short while.

But if the response comes over 3 minutes after the request, then the application receives nothing.

On the backend, I've set a breakpoint. After 3 minutes, I've let backend to send a response to the app, but there nothing comes. No success, no error, just nothing.

If I make an HTTP request without SSLVerification, then I receive a response also after 6 minutes. Instead, HTTPS requests longer than 3 minutes just don't want to work.

Change RetryPolicy to make many requests it's just a workaround and it's not an option.

like image 376
anatoli Avatar asked Apr 24 '19 07:04

anatoli


2 Answers

The response is taking too long to be received in the device and thus the Volley is having a TimeoutError. You need to modify the default timeout value like the following before sending a request to your server.

req.setRetryPolicy(new RetryPolicy() {
    @Override
    public int getCurrentTimeout() {
        return 360000;
    }

    @Override
    public int getCurrentRetryCount() {
        return 5000;
    }

    @Override
    public void retry(VolleyError error) throws VolleyError {

    }
});

queue.add(req);
like image 138
Reaz Murshed Avatar answered Nov 08 '22 02:11

Reaz Murshed


Try this

req.setRetryPolicy(new DefaultRetryPolicy(90000, 1, 1f));
like image 35
VIKAS SHARMA Avatar answered Nov 08 '22 01:11

VIKAS SHARMA