Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The connection errored: Failed host lookup: Error: SocketException: Failed host lookup: #2058

Closed
farrukhnajmi opened this issue Dec 6, 2023 · 3 comments

Comments

@farrukhnajmi
Copy link

Package

dio

Version

^5.3.4

Operating-System

Linux

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.13.1, on Ubuntu 22.04.3 LTS 6.2.0-37-generic, locale en_US.UTF-8)
    • Flutter version 3.13.1 on channel stable at /home/farrukh/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e1e47221e8 (4 months ago), 2023-08-22 21:43:18 -0700
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/farrukh/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /home/farrukh/Android/Sdk
    • Java binary at: /home/farrukh/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.1)
    • Android Studio at /home/farrukh/android-studio
    • Flutter plugin version 76.3.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Connected device (3 available)
    • SM A326U (mobile) • adb-RFCR90Y104K-zEsC1a._adb-tls-connect._tcp • android-arm64  • Android 13 (API 33)
    • Linux (desktop)   • linux                                        • linux-x64      • Ubuntu 22.04.3 LTS 6.2.0-37-generic
    • Chrome (web)      • chrome                                       • web-javascript • Google Chrome 120.0.6099.62

[✓] Network resources
    • All expected network resources are available.

Dart Version

3.1.0

Steps to Reproduce

  1. Install my app from AndroidStudio directly to my phone
  2. App does an HTTP get request on a REST service that has an http (not https) url using [retrofit: ^4.0.3, retrofit_generator: ^8.0.4 and dio: ^5.3.4
  3. The HTTP get call returns normally with a json response
  4. I now build the app bundle using flutter build appbundle
  5. I upload the generated build/app/outputs/bundle/release/app-release.aab file to Google Playstore in an Internal Testing release track
  6. I Install the newly uploaded version of my app to my phone using the link provided by Play Console under title "How testers join your test"
  7. App does an HTTP get request on a REST service that has an http (not https) url using [retrofit: ^4.0.3, retrofit_generator: ^8.0.4 and dio: ^5.3.4
  8. The HTTP get call returns with an error stacktrace (see actual result section)

I am sorry but I am not sure how to create a minimal reproducible test case for this. Open to suggestions.

Expected Result

The HTTP get call should return normally with a json response

Actual Result

The HTTP get call returns with an error stacktrace

Error: DioException [connection error]: The connection errored: Failed host lookup: 'myhost.com' This indicates an error which most likely cannot be solved by the library.
Error: SocketException: Failed host lookup: 'myhost.com' (OS Error: No address associated with hostname, errno = 7) #0      DioMixin.fetch.<anonymous closure> (package:dio/src/dio_mixin.dart:507)
#1      _RootZone.runUnary (dart:async/zone.dart:1661)
#2      _FutureListener.handleError (dart:async/future_impl.dart:174)
#3      Future._propagateToListeners.handleError (dart:async/future_impl.dart:852)
#4      Future._propagateToListeners (dart:async/future_impl.dart:873)
#5      Future._completeError (dart:async/future_impl.dart:649)
#6      _SyncCompleter._completeError (dart:async/future_impl.dart:60)
#7      _Completer.completeError (dart:async/future_impl.dart:26)
#8      Future.any.onError (dart:async/future.dart:620)
#9      _RootZone.runBinary (dart:async/zone.dart:1666)
#10     _FutureListener.handleError (dart:async/future_impl.dart:171)
#11     Future._propagateToListeners.handleError (dart:async/future_impl.dart:852)
#12     Future._propagateToListeners (dart:async/future_impl.dart:873)
#13     Future._completeError (dart:async/future_impl.dart:649)
#14     Future._chainForeignFuture.<anonymous closure> (dart:async/future_impl.dart:550)
#15     _microtaskLoop (dart:async/schedule_microtask.dart:40)
#16     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)
@farrukhnajmi farrukhnajmi added h: need triage This issue needs to be categorized s: bug Something isn't working labels Dec 6, 2023
@farrukhnajmi farrukhnajmi changed the title The connection errored: Failed host lookup: The connection errored: Failed host lookup: Error: SocketException: Failed host lookup: Dec 6, 2023
@kuhnroyal
Copy link
Member

Did you set the internet permission in the android manifest?

@IvanYue

This comment was marked as off-topic.

@farrukhnajmi
Copy link
Author

Did you set the internet permission in the android manifest?

That was the issue! Thank you so much. After adding the internet permission:

<uses-permission android:name="android.permission.INTERNET"/>

in android/app/src/main/AndroidManifest.xml and rebiuilding appbundle using flutter build appbundle, deployimng to Play Console and installing on my phone all is well.

Weird thing is that this permission did not seem to be required in my last release. Thanks again for resolving my issue.

@AlexV525 AlexV525 added i: not related and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants