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

SocketException: Connection timed out (OS Error: Connection timed out, errno = 110) #831

Closed
aliaafreen opened this issue Nov 24, 2022 · 12 comments
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@aliaafreen
Copy link

When using http post for getting data from server it gives error
SocketException: Connection timed out (OS Error: Connection timed out, errno = 110)
It is working fine in iOS but in android sometimes screen get stuck and not getting any data,
after few seconds gives connection timeout os error.

Sometime it is working properly in android too but most of the time not giving any data.

flutter and http package version
http: ^0.13.4
flutter - 2.10.4

Complete error message
E/flutter (30573): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = app.ratnasangh.com, port = 37230
E/flutter (30573): #0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:682:35)
E/flutter (30573): #1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1817:26)
E/flutter (30573): #2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
E/flutter (30573): #3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:237:22)
E/flutter (30573): #4 SecureSocket.startConnect (dart:io/secure_socket.dart:60:28)
E/flutter (30573): #5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2438:24)
E/flutter (30573): #6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2834:12)
E/flutter (30573): #7 _HttpClient._getConnection (dart:_http/http_impl.dart:2839:12)
E/flutter (30573): #8 _HttpClient._openUrl (dart:_http/http_impl.dart:2698:12)
E/flutter (30573): #9 _HttpClient.openUrl (dart:_http/http_impl.dart:2570:7)
E/flutter (30573): #10 IOClient.send (package:http/src/io_client.dart:35:38)
E/flutter (30573): #11 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:38)
E/flutter (30573): #12 BaseClient.post (package:http/src/base_client.dart:32:7)
E/flutter (30573): #13 post. (package:http/http.dart:69:16)
E/flutter (30573): #14 _withClient (package:http/http.dart:164:20)
E/flutter (30573): #15 post (package:http/http.dart:68:5)
E/flutter (30573): #16 Functions.httpPost (package:ratnasangh/utilities/functions.dart:38:26)
E/flutter (30573): #17 ApiService.getSantList (package:ratnasangh/services/api_services.dart:1016:57)
E/flutter (30573): #18 _VichranViharState.getStories (package:ratnasangh/screens/vichran_vihar.dart:38:63)
E/flutter (30573): #19 _VichranViharState.initState (package:ratnasangh/screens/vichran_vihar.dart:31:5)
E/flutter (30573): #20 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4893:57)
E/flutter (30573): #21 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4729:5)
E/flutter (30573): #22 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (30573): #23 Element.updateChild (package:flutter/src/widgets/framework.dart:3524:20)
E/flutter (30573): #24 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #25 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #26 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
E/flutter (30573): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #30 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #31 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #33 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #34 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #35 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #36 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
E/flutter (30573): #37 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
E/flutter (30573): #38 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #39 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #40 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #41 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #42 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #43 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #44 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #45 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #46 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #47 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #48 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #49 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #50 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #51 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #53 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
E/flutter (30573): #54 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #55 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #56 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #57 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
E/flutter (30573): #58 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #59 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
E/flutter (30573): #60 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #61 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #62 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #63 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #64 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #66 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #67 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #68 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #69 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #70 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #71 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #72 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #73 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #74 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #75 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #76 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #77 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
E/flutter (30573): #78 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #80 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #81 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #82 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #83 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #84 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #85 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #86 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #89 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #90 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #91 StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
E/flutter (30573): #92 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #93 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #94 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #95 ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
E/flutter (30573): #96 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #97 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
E/flutter (30573): #98 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #99 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #100 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #101 StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
E/flutter (30573): #102 Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
E/flutter (30573): #103 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (30573): #104 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (30573): #105 Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (30573): #106 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
E/flutter (30573): #107 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
E/flutter (30573): #108 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
E/flutter (30573): #109 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
E/flutter (30573): #110 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
E/flutter (30573): #111 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
E/flutter (30573): #112 _rootRun (dart:async/zone.dart:1426:13)
E/flutter (30573): #113 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (30573): #114 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
E/flutter (30573): #115 _invoke (dart:ui/hooks.dart:151:10)
E/flutter (30573): #116 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
E/flutter (30573): #117 _drawFrame (dart:ui/hooks.dart:115:31)
E/flutter (30573):

@aliaafreen aliaafreen added package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 24, 2022
@OsamaAldawoody
Copy link

I have the same issue!

@kodiworm
Copy link

I have the same issue.

2 similar comments
@ajinspiro
Copy link

I have the same issue.

@mehmetcannn0
Copy link

I have the same issue.

@AlejoG1996
Copy link

Hola! encontraron alguna solución

@shrijanRegmi
Copy link

Having same issue!

@angwarati
Copy link

Having same issue, this is affecting both iOS and Android production! I'm using http: any and flutter Channel stable, 3.3.10.

@bkan36
Copy link

bkan36 commented Sep 28, 2023

I've seen that runZonedGuarded can catch it
I tried it and worked for 1 day lol but now doesn't works anymore with the same code... I don't know why.

here's my code (I use Dio)

Future<Response?> post(String path, dynamic parameter) async =>
      runZonedGuarded<Future<Response?>>(() async {
        return await client.post(path,
            data: json.encode(parameter),
            options: Options(
              headers: headers
                ..addAll(<String, String>{
                  'Authorization': await localData.read(accessTokenName) ?? ''
                }),
            ));
      }, (error, stack) {
        throw Exception('SERVER DOWN');
      });

@natebosch
Copy link
Member

The error in the original comment looks unrelated to package:http - the stack points into the dart:io native libraries.

If you have a minimal reproduction which demonstrates a bug in HttpClient from dart:io you can file an issue at https://github.com/dart-lang/sdk/issues

Exceptions using networking in flutter can sometimes come from permission issues.
https://docs.flutter.dev/data-and-backend/networking

If that doesn't help, stack overflow or the flutter discord might be a better place to get answers about using the network in flutter.

@aaluyi
Copy link

aaluyi commented Aug 13, 2024

I have the same issue with http:v1.2.2 in android 15.0, my flutter version is 3.19.5, my scenario is upload image, it occurs problem sometimes.
I have looked for many similiar issues in StackOverflow/Github Flutter Repo/Github Http Repo, however, no solution to this issue.
Is there more infomation about this issue?

@ajinspiro
Copy link

ajinspiro commented Aug 13, 2024

as far as i know there is no fix for this. we need to use a domain instead of using an ip adress. it works when used with a domain

@aaluyi
Copy link

aaluyi commented Aug 13, 2024

as far as i know there is no fix for this. we need to use a domain instead of using an ip adress. it works when used with a domain

Actually, my request uses the domain, not ip address. Is this issue related to domain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests