dio icon indicating copy to clipboard operation
dio copied to clipboard

Failed host lookup error at every request after disconnecting and reconnecting to internet.

Open albe-jj opened this issue 10 months ago • 3 comments

Package

dio

Version

5.1.2

Operating-System

Windows

Adapter

Default Dio

Output of flutter doctor -v

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.21.0-5.0.pre.7, on Microsoft Windows [Version 10.0.19045.4170], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.8.3)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.87.2)
[√] Connected device (3 available)
[√] Network resources

Dart Version

3.4.0-222.0.dev

Steps to Reproduce

The application every once in a while (once every two days) throws me a Failed host lookup and cannot send any further request although there is internet connection and the host can be resolved. Most of the time the connection is interrupted and I get the Failed host lookup error then the app continues working as expected after connecting back to the internet. But when I get this issue the dio instance keeps throwing the Failed host lookup error at every subsequent request although connection is available and host can be resolved. By restarting the application I can again send requests as normal.

DioException [connection error]: The connection errored: Failed host lookup: 'qdrive.qutech.tudelft.nl' This indicates an error which most likely cannot be solved by the library.
Error: SocketException: Failed host lookup: '<myhost.com>' (OS Error: No such host is known.
, errno = 11001)
#0   DioMixin.fetch.<anonymous closure> (package:dio/src/dio_mixin.dart:510)
#1   _rootRunUnary (dart:async/zone.dart:1407)
#2   _CustomZone.runUnary (dart:async/zone.dart:1308)
#3   _FutureListener.handleError (dart:async/future_impl.dart:181)
#4   Future._propagateToListeners.handleError (dart:async/future_impl.dart:859)
#5   Future._propagateToListeners (dart:async/future_impl.dart:880)
#6   Future._completeError (dart:async/future_impl.dart:660)
#7   _SyncCompleter._completeError (dart:async/future_impl.dart:63)
07:53:07.841 (+9:07:44.900048)```



### Expected Result

I would expect that even if it fails to look up the host once,  `Failed host lookup` the coming requests go through when internet connection is back. But that is not always the case. 

### Actual Result

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 such host is known. , errno = 11001) #0 DioMixin.fetch. (package:dio/src/dio_mixin.dart:510) #1 _rootRunUnary (dart:async/zone.dart:1407) #2 _CustomZone.runUnary (dart:async/zone.dart:1308) #3 _FutureListener.handleError (dart:async/future_impl.dart:181) #4 Future._propagateToListeners.handleError (dart:async/future_impl.dart:859) #5 Future._propagateToListeners (dart:async/future_impl.dart:880) #6 Future._completeError (dart:async/future_impl.dart:660) #7 _SyncCompleter._completeError (dart:async/future_impl.dart:63) 07:53:07.841 (+9:07:44.900048)

albe-jj avatar Apr 09 '24 06:04 albe-jj

You can verify if the behavior occurred when using package:http or HttpClient, so we can quickly determine which part fails.

AlexV525 avatar Apr 09 '24 11:04 AlexV525

Thanks for the reply. How can I verify this?

You can verify if the behavior occurred when using package:http or HttpClient, so we can quickly determine which part fails.

albe-jj avatar Apr 14 '24 09:04 albe-jj

By writing a minimal example to make requests using them.

AlexV525 avatar Apr 14 '24 09:04 AlexV525

I found out it was a problem I my code logic, when there was no connection available. Closing the issue.

albe-jj avatar May 19 '24 07:05 albe-jj

@albe-jj what was the error? I'm kinda having a similar problem to this.

joabsantos avatar May 20 '24 11:05 joabsantos

I have the same problem, how should I solve it?

xxm-wu avatar Aug 05 '24 06:08 xxm-wu