flutter: Exception : SocketException: Connection failed only on iOS Simulator

569

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.

Share:
569
Chathuranga Jayawardhana
Author by

Chathuranga Jayawardhana

I'm a cool guy, interested in programming, electronics and cars, currently working as a mobile application developer.

Updated on December 29, 2022

Comments

  • Chathuranga Jayawardhana
    Chathuranga Jayawardhana over 1 year

    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.

    • Tapas Pal
      Tapas Pal almost 3 years
      Facing the same. Did you found any workaround?
    • Chathuranga Jayawardhana
      Chathuranga Jayawardhana almost 3 years
      @TapasPal nope, still having the issue, I have reported this on flutter github project as well, but still waiting for any reply. I was facing this issue when i tried to access REST api with self signed SSL certificate, using this method stackoverflow.com/questions/59622087/…, turns out APIs with proper SSL certificates seems to be working without any issue.
  • wisetap.com
    wisetap.com about 2 years
    thanks a lot! I uninstalled my avast antivirus and worked