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

there are too many DioErrorType.connectTimeout reported in sentry #1230

Closed
catmaomao opened this issue Jul 26, 2021 · 17 comments
Closed

there are too many DioErrorType.connectTimeout reported in sentry #1230

catmaomao opened this issue Jul 26, 2021 · 17 comments

Comments

@catmaomao
Copy link

DioError [DioErrorType.connectTimeout]: Connecting timed out [50000ms]
#0 DioMixin.assureDioError (package:dio/src/dio_mixin.dart:819)
#1 DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:678)

#2 DioMixin.fetch.. (package:dio/src/dio_mixin.dart:586)

I have a timer task that requests the network every 30 seconds.
But I found a lot of network connection timeout problems in sentry background, I don't know why?

@stale
Copy link

stale bot commented Sep 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.

@stale stale bot added the stale label Sep 3, 2021
@macortesn
Copy link

I have the same issue, it's random. I try make any request the request fails and try again and the request works fine. I'm using the lastest version of Dio.
image

@stale stale bot removed the stale label Sep 22, 2021
@macortesn
Copy link

Any update?

@BlackCatHehe
Copy link

I have the same error.

@cyjaysong
Copy link

You can set which errors to ignore during initialization.

https://docs.sentry.io/platforms/flutter/configuration/filtering/

@markphillips100
Copy link

I've been noticing a similar connect timeout when using the http2 adapter. I can always reproduce the issue using a test client and server - the steps require the ability to enable/disable a URL endpoint from accepting connections.

I don't know if it's 100% related but certainly whilst I've been developing client and api locally and whenever I stopped my server hosting my api and the client makes a call, all new connections fail with the connect timeout.

  1. Server endpoint turned off
  2. Start client app and trigger an api request. This will fail after the connect timeout passes.
  3. Start server endpoint.
  4. Trigger another api request. This will fail to connect and will continue to do so.

NOTE: I don't see this issue when I don't configure the http2 adapter on the Dio instance. It's only with http2 adapter.

I've modified a local version of the http2 adapter to get it to work, specifically the connection_manager_imp.dart. I noticed that the first socket connect failure throws an exception, as expected, but this exception means the future is no longer valid so shouldn't be added to the _connectFutures list here. The next connection attempt that passes through the getConnection function finds the failed future and when it's awaited it fails....and will do for every connection attempt from here onwards.

The "fix" for me was to add a try/catch block around the await of the future so it can be removed from the _connectFutures list and the error rethrown. It's not elegant but it seems to work:

      try {
        transportState = await _initFuture;
      } on Exception {
        var _ = _connectFutures.remove(domain);
        rethrow;
      }

This doesn't appear to affect the ability of the adapter to reuse connections that occur frequently after each other, when they connect of course ;-)

So I say, if you are using the http2_adapter you may want to consider this might be the issue.

@lirantzairi
Copy link

I'm also getting this issue. I have a service running periodically every 3 minutes. Crashlytics shows that in production hundreds of users are getting connectTimeout from Dio. @wendux Any update please?

@kuhnroyal
Copy link
Member

Is everyone here using the http2 adapter?

@namdp
Copy link

namdp commented Jan 7, 2022

any update? getting too much errors

@kuhnroyal
Copy link
Member

@namdp Can you answer my previous question?

@namdp
Copy link

namdp commented Jan 8, 2022

@namdp Can you answer my previous question?

@kuhnroyal. No, i'm not using http2 adapter

@kuhnroyal
Copy link
Member

Thanks, unfortunately I don't see what can be done here.
I also use Dio in production apps and there are many timeouts in Sentry, but usually they are just connection problems that you have to live with in mobile development.

@votruk
Copy link

votruk commented May 17, 2022

The bug is happening in my project as well. Did anybody find a solution except retrying? I'm not using the http2 adapter btw.

@MohamedSonata
Copy link

MohamedSonata commented Jun 7, 2022

If you are using a Localserver: You Should every time when you restart your pc changing the IP Address

BaseOptions( baseUrl: // here changing the ip address every time after restart the internet or the pc to your local ip address Example :http://192.168.1.4/: server port, ));

and same solution for your Online domain be sure is the correct URL You're using

@OmarBakry-Globalits
Copy link

This problem still occurs till now I don't know why this issue marked as closed please open it again I'm using the latest version of Dio (dio: ^5.0.1) and still getting connection timeout every time although the code was working yesterday without any update !!!

I'm using this API
https://www.boredapi.com/api/activity/

@kuhnroyal
Copy link
Member

It is very likely that there is nothing wrong in dio here, this ticket is not actionable. In mobile connectivity, timeouts are not unusual. If you have a specific use case were you think this occurs and you think it may be a problem with dio, please create a new issue following the template and include a reproducible sample.

Also check the configuration of your timeouts and try with the defaults instead, if you have custom timeouts set.

@daniel-py
Copy link

It is very likely that there is nothing wrong in dio here, this ticket is not actionable. In mobile connectivity, timeouts are not unusual. If you have a specific use case were you think this occurs and you think it may be a problem with dio, please create a new issue following the template and include a reproducible sample.

Also check the configuration of your timeouts and try with the defaults instead, if you have custom timeouts set.

Hi there,
I have noticed this error shows up on IOS devices when the app is backgrounded. I am not the only one who has noticed this. There was an issue opened on this in 2019 that was never resolved but got closed by the bot.
ONCE THE APP GETS BACKGROUNDED ON IOS (not too sure about Android), dio throws this error: DioErrorType.CONNECT_TIMEOUT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests