Android Volley double post when have slow request

后端 未结 18 2740
生来不讨喜
生来不讨喜 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:39

    I asked a similar question here:

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

    I managed to solve this issue by setting the keep-alive property to false inside Android, e.g.:

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

    I added this line of code inside the class where I import requestqueue and make the requests.

    Also, check if you server has the keep-alive header.

    This post helped get to the solution.

提交回复
热议问题