In one of my application, I am sending request to server using volley
provided by Google.
Problem : Timeout and error object is null on onErrorResponse(VolleyError error)
What i have tried so far :
1) First I got null error object so solved it by using below code :
@Override
protected void deliverResponse(String response) {
super.deliverResponse(response);
}
@Override
public void deliverError(VolleyError error) {
super.deliverError(error);
DebugLog.e("deliverResponse", "getNetworkTimeMs : " + error.getNetworkTimeMs());
}
So far I have got that there is timeout
happening when I got error object null
.
2) Now Application is for Android
and iOS
and web
but timeout
happens only for Android
.
Volley log for requests :
BasicNetwork.logSlowRequests: HTTP response for request
Edited Note :
Web services develoed at server end is same for all three instances (Android , Web and iOS).
Timeout
happens when too many users makes requests to the server.
I have set time out to 2 minutes though volley throws timeout in 30 seconds only sometimes.
I have many answers to change server but as it is not possible so any other solution please.
I also like to add that if i can get more information about when timeout can be possible in volley ?
References I have been gone through :
Optimizing Volley
httpclient-often-times-out-using-wifi-is-going-fine-with-3g
long_xmlhttprequest_ajax_requests_timeout_on_android
Edited :
I have also set retry policy as below:
request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
And also i do not want to retry if connection timeout.
How can i make efficient service call that can solve problem for timeout
.
Any help will be appriciated.
Thanks.
Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. Volley is available on GitHub. Volley offers the following benefits: Automatic scheduling of network requests.
volley (lib) is not deprecated. Why would it be? More importantly, if it works, why does it matter? Deprecated doesn't necessarily mean something is bad.
Volley is an HTTP library that makes networking very easy and fast, for Android apps. It was developed by Google and introduced during Google I/O 2013. It was developed because there is an absence in Android SDK, of a networking class capable of working without interfering with the user experience.
As i have tried to get solution of this issue for about two months, I did not get any perfect solution. Though I analyze some facts as below :
HttpURLConnection
but still getting same issue over there.So I think this issue is not specific from volley, but you getting this issue then i would suggest to increase server performance with customizing below RetryPolicy
:
int x=2;// retry count
request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
x, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
Hope it will help.
Suggestions are always welcome :)
Please comment below if you found more proper solution.
Thanks.!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With