I am facing an issue with Flutter 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
- Instead of domain I executed the API service call using the IP address, which took only less than a second (SSL verification disabled in HTTP plugin)
- 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
- 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?
flutter doctor -v
[√] Flutter (Channel stable, 3.3.6, on Microsoft Windows [Version 10.0.22000.1219], locale en-US)
• Flutter version 3.3.6 on channel stable at C:\Applns\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6928314d50 (6 weeks ago), 2022-10-25 16:34:41 -0400
• Engine revision 3ad69d7be3
• Dart version 2.18.2
• DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\Siju\AppData\Local\Android\sdk
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33110.190
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] Connected device (4 available)
• 2201116SI (mobile) • b75ac32a6d34 • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.1219]
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.123
• Edge (web) • edge • web-javascript • Microsoft Edge 107.0.1418.62
[√] HTTP Host Availability
• All required HTTP hosts are available