I am getting the following error when I try to invoke a REST API with dart HTTP module, this happens only on iOS Simulator, tried running the same code on an iOS Device and Android Emulator, working fine on both of them.
This is what I am getting when I log the exception,
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 28.0s
Debug service listening on ws://127.0.0.1:51060/OGZYZc5p7EM=/ws
Syncing files to device iPhone 12 Pro Max...
flutter: Exception : SocketException: Connection failed, address = my.domain.api.net, port = 443
iOS Development tools : XCode Version 12.5 (12E262)
flutter doctor output :
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-LK)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.56.1)
[✓] Connected device (3 available)
• No issues found!
Tried to access my API URL with Safari on Simulator and it is working fine too, apart from the flutter exception, I am not getting any other information/logs.
The reason for my issue has to do something with Sophos Antivirus, I have removed Sophos and was able to solve the issue. I was getting a similar socket exception when I try to use flutter pub get
, but only with one of my internet connections, it is working fine when I switch to another connection, I tried to get flutter pub get
working by removing the Sophos, and it solves both flutter pub get
issue and the connection issue with the iOS simulator.