http icon indicating copy to clipboard operation
http copied to clipboard

In Android 12+, the REST API calls are very slow in WiFi network

Open SijuKJ opened this issue 2 years ago • 2 comments

I have an issue with the Flutter HTTP plugin in the Android 12+ version. App-consuming REST API calls using the Flutter HTTP plugin (Version: 0.13.5). All API calls are HTTPS service calls with the domain name. API calls take 10+ seconds to provide the response whereas the same API calls took only less than a second in mobile data networks. The same API calls I tried using Java Client and Postman, all responses took only less than a second to get a response.

During the troubleshooting, I tested the following scenarios using Wifi Network

  1. Instead of the domain, I executed the API service call using the IP address, which took only less than a second (SSL verification disabled in the HTTP plugin)
  2. Tested API call using connection keep-alive: true, then the first call took 10+s after that subsequent calls took only less than a second
  3. One interesting fact is that I experienced a problem only in Android 12+, the Android 11 device worked on a WiFi network, and it took less than a second for a service call. Now I understood Wifi based API calls always take 10 Seconds + actual service call time (eg 400 ms hence it would be like 10.400 seconds).

Is there any specific reason for this issue?

Note: I came to understand that issue is related to DNS resolving, ie During the initial call it tries to connect using IPv6 then it tries to connect using IPv4. If so, is there any option in the HTTP plugin to force the IPv4 version instead of the IPv6

SijuKJ avatar Dec 04 '22 14:12 SijuKJ

Same problem here, did you figure out a solution?

davidhel avatar Nov 29 '23 13:11 davidhel

i have same problem, begin with expired domain, try renewal domain and can access in browser, but inside flutter cant access to the domain api

bagusindrayana avatar Apr 05 '24 12:04 bagusindrayana