Connection closed before full header was received, where should I try catch exactly?
Hasankanso opened this issue · 8 comments
E/flutter ( 5900): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Connection closed before full header was received
E/flutter ( 5900): #0 IOClient.send (package:http/src/io_client.dart:62:7)
E/flutter ( 5900): <asynchronous suspension>
E/flutter ( 5900): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:91:38)
E/flutter ( 5900): #2 BaseClient.get (package:http/src/base_client.dart:27:7)
E/flutter ( 5900): #3 GoogleWebService.doGet (package:google_maps_webservice/src/utils.dart:53:52)
E/flutter ( 5900): #4 GoogleMapsPlaces.autocomplete (package:google_maps_webservice/src/places.dart:164:46)
E/flutter ( 5900): #5 PlacesAutocompleteState.doSearch (package:pickapp/utilities/pickapp_google_places.dart:428:33)
E/flutter ( 5900): #6 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 5900): #7 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 5900): #8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 5900): #9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter ( 5900): #10 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter ( 5900): #11 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:385:25)
E/flutter ( 5900): #12 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:250:5)
E/flutter ( 5900): #13 _StartWithStreamSink.add (package:rxdart/src/transformers/start_with.dart:16:10)
E/flutter ( 5900): #14 forwardStream.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:34:49)
E/flutter ( 5900): #15 forwardStream.runCatching (package:rxdart/src/utils/forwarding_stream.dart:24:12)
E/flutter ( 5900): #16 forwardStream.<anonymous closure>.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:34:28)
E/flutter ( 5900): #17 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 5900): #18 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 5900): #19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 5900): #20 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter ( 5900): #21 _DelayedData.perform (dart:async/stream_impl.dart:611:14)
E/flutter ( 5900): #22 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
E/flutter ( 5900): #23 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:687:7)
E/flutter ( 5900): #24 _rootRun (dart:async/zone.dart:1182:47)
E/flutter ( 5900): #25 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 5900): #26 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 5900): #27 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter ( 5900): #28 _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 5900): #29 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 5900): #30 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 5900): #31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter ( 5900): #32 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 5900): #33 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
it happens when I type any letter, and go back before getting any response
The same issue, please help us!!!!
Hey I'm also facing same issue. please help me.
unable to reproduce, can you test with version 0.3.0 ?
yes it's still there, although the error message is a bit different now:
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: SocketException: Connection attempt cancelled, host: maps.googleapis.com, port: 443
we solved it by adding a try catch to the line 429 in src/flutter_google_places.dart:
var res;
try {
res = await _places!.autocomplete(
value,
offset: widget.offset,
location: widget.location,
radius: widget.radius,
language: widget.language,
sessionToken: widget.sessionToken,
types: widget.types!,
components: widget.components!,
strictbounds: widget.strictbounds!,
region: widget.region,
);
} catch (e) {
print(e);
}
if (res == null) {
onResponse(null);
return;
}
again, this only happens when the search page is popped (closed) before a response is received.
This doesn't fix the error in my code. Have to get a different library.
I have updated this package, please use the following:
flutter_google_places:
git:
url: https://github.com/fluttercommunity/flutter_google_places
ref: v0.3.2
I have updated this package, please use the following:
flutter_google_places: git: url: https://github.com/fluttercommunity/flutter_google_places ref: v0.3.2
Still got the same error after the update
Hi. I have a similar issue with my flutter app.
When I call an API function, the app crashes with the error "Connection closed before full header was received" on my mobile (samsung, Android).
If I connect using wifi, the call works correctly. If I use emulatores, the app works correctly too. No problems testing with postman.
If I call the same code linking to another API url (but it's the same API code), I do not have any problems.
Flutter doctor was ok. My mobile works correctly with any other app/request
Here's the code
Uri l_Uri = Uri.parse("http://xxxx:xxxx/api/Login");
final response = await http.post(l_Uri,
body: l_body,
headers: {
"Accept": "application/json",
"content-type": "application/json",
});
where body:
{
"UserName": "***",
"Password": "***",
"SvrUsername": "***",
"SvrPassword": "***"
}
After a few seconds, the error "Connection closed before full header was received"
Can you help me?