asynchronous - Android Volley makes 2 requests to the server when retry policy is set to 0 -


I am working on an Android project which uses volley for async requests and image caching. Either way the request is crashing on the server twice, even when I have retried the policy to retry. I tried to override the values ​​from the DefaultRetryPolicy object without any success. Here are some sample codes:

Request:

  @Override public zero gravarVendaMobile (last usuario usuarioAutenticado , Last AsyncCallback & lt; String & gt; Callback) {obterParametrosDeInicializacao () New (New.DoneCallback & lt; ParametrosDeInicializacao & gt; () {@Override Public on Zero Don (Ultimate ParametrosDeInicializacao param) {requestQueue.add (setDefaultRetryPolicy) ( New string request (method POST, urlPara (GRAVAR_VENDA_MOBILE, usuarioAutenticado.getFilial (), usuarioAutenticado.getCodigo ()), listener (Callback), //errorListener (R.string.could_not_load_produtos, callback) New ErrorListener () {@Override Public Zero onErrorResponse (VolleyError Error) {callback.onError (New MessageCodeException (error.networkResponse.statusCode, Error))}} ) {@Override Public map & lt; string, string & gt; getHeaders () throws AuthFailureError {Map & quot; string, string & gt; Header = new HashMap & LT; String, string & gt; (); Headers.put ("encoding", "UTF-8"); Header .put ("accept", "app / jason"); Header .put ("content-type", "app / jason; charset = UTF-8"); Return header;}}));}};}   

Retry policy:

  Private request & lt ;? & Gt; SetDefaultRetryPolicy (request & lt;? & Gt; request) {request.setRetryPolicy (New DefaultRetryPolicy (30000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); Return request;}   

Actually, I want to set the timeout of 30 seconds with 0 retrieve.

If I increase the number of retrieves then it expects that works, but if I set it to 0 then 2 requests.

Here's some help needed.

Edit

In order to keep false things inside Android, I have been able to solve my problem, for example:

  System.setProperty ("http.keepAlive", "false");   

I've added the code of this line inside of the square where I import and request a request.

Also, check whether your server has a fixed header.

There was a solution to this.

I use it to set poles again:

 < Code> myRequest.setRetryPolicy (new DefaultRetryPolicy (0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -