Android Volley double post when have slow request

后端 未结 18 2748
生来不讨喜
生来不讨喜 2020-11-28 04:06

I have a problem with Volley POST request on slow network. Everytime I see BasicNetwork.logSlowRequests in my LogCat, my POST request is executed twice or more

18条回答
  •  我在风中等你
    2020-11-28 04:49

    Tried lot of things but in the end nothing helped. Finally, I figured out following combination of changes:

    sr.setRetryPolicy(new DefaultRetryPolicy(0,-1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    

    And in your hurl connection in application class, add this:

    httpsURLConnection.setChunkedStreamingMode(0);
    

    This worked smoothly to stop Volley hitting multiple request at server.

提交回复
热议问题