Repository navigation
http: Unhandled Exception: Connection closed before full header was received #41573
Description
Activity
Issue exist on Master and stable.
- addedc: crashStack traces logged to the consoleStack traces logged to the console
on Sep 29, 2019 @Gnpiwano Please provide the info about devices on which you encounter it. Does it happen on both ios and android? does it happen on both emulator and physical device?
- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Sep 29, 2019 Hi @BondarenkoStas,
I tested it on iphone XS(real device), iphone R(simulator), Pixel 3 (real device). So it looks like the bug is not platform specific.Reacted by Brad, Peter Aleksander Bizjak, radrt and Dominik Roszkowski- removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Sep 29, 2019 I also tried to http.get www.google.nl and that worked fine so it looks likes it has anything to do with this Url.
The api is from a well known bank so it should work fine and because natively it does work normally.
Reacted by Shailesh and ankitch29Hi @BondarenkoStas , I am also facing the same issue while fetching data from the server. I am using Swagger Client which frequently throws exception i.e. 'Connection closed before full header was received'. Swagger is using package:http/http.dart [pub.dev> package http: ^0.12.0+2].
Reacted by Nilesh Unde, Basavraj Kotagond and Dominik RoszkowskiDoes anyone fix this issue? What did you do?
@HumbleCarl ,
I fixed it for now by creating a http channel and do the http request natively and then return the response.@HumbleCarl ,
I fixed it for now by creating a http channel and do the http request natively and then return the response.How ?
@mohamedashraf8850
Can't share that specific code, but use this method channel. With method channels you can define your postRequest, GetRequest etc en include the body and params as arguments. Not ideal because but works:)- addeddependency: dartDart team may need to help usDart team may need to help us
on Jan 15, 2020 @Gnpiwano
I'm glad that you fixed the problem.
Closing the issue,
if you disagree please write in the comments and I will reopen it.
Thank you91 remaining items
I'm also having this issue while making a simple call to one of my google cloud functions from my flutter app in an iOS simulator. The HTTP request had not returned (i verified that the cloud function was still running and had not returned) and I get this error.
Reacted by David GilI suspect this issue is due to some of the SSL cipher suites not working properly.
My environment has several windows 10 devices, each of them hosting a local CouchDB with SSL enabled using a self-sign certificate.
My app receives this exception when connecting to some of the CouchDB instances.After some investigation, the problematic device has
ECDHE-RSA-CHACHA20-POLY1305configured as CouchDB SSL cipher suite. I was able to resolve the issue by changing the chiper suite toECDHE-RSA-AES128-GCM-SHA256.I'm having the same issue on real devices.
The root cause of the original issue has been fixed with the addition of the
SecurityContext.allowLegacyUnsafeRenegotiationproperty.You could please file new bugs for unrelated HTTP issues? Ideally with Dart itself unless they seem to be related to Flutter.
I did receive the same issue. Also this issue occurs randomly for me. This occurs at times if I keep triggering a http call again and again.
tested on: Honor 9x (physical device)I/flutter ( 8873): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 8873): Connection closed before full header was received
I/flutter ( 8873):
I/flutter ( 8873): #0 IOClient.send (package:http/src/io_client.dart:66:7)
I/flutter ( 8873):
I/flutter ( 8873): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)
I/flutter ( 8873):
I/flutter ( 8873): #2 ApiClient.post (package:api_client/src/api_client.dart:130:18)
I/flutter ( 8873):
I/flutter ( 8873): #3 CommissionApiImp.getMonthlyCommissionReport (package:yatrikart_data_layer/src/commission/commission_remote.dart:119:24)
I/flutter ( 8873):
I/flutter ( 8873): #4 CommissionRepoImp.getMonthlyCommissionReport (package:yatrikart_repo_layer/src/commission/commission_repo.dart:91:13)
I/flutter ( 8873):
I/flutter ( 8873): #5 CommissionBloc._mapMonthlyCommissionReportClickedToState (package:yatrikart_hawkers_app/commision/bloc/commision_bloc.dart:137:11)
I/flutter ( 8873):
I/flutter ( 8873): #6 Bloc.on..handleEvent (package:bloc/src/bloc.dart:211:13)
I/flutter ( 8873):
I/flutter ( 8873): ----------------------------------------------------We ran into this(?) error when using the dart tooling to publish dart packages to a private (JFrog based) pub-repository.
Strangely it only happened on CI and only on the third package to publish (the two before where published fine).
Also it appeared from nowhere (previous tests for the new CI setup with the same packages didn't fail).
It went away after we changed the order in which we packed and published the packages 🤷 .Through without reordering the order we publish packages it happens reproducible.
We're seeing a lot of these when using the Android 13 Beta 4.1 (emulated).
- There are about 3-4 concurrent requests
- Creating and closing a Client for each request
It does no longer occur when
- reusing the same Client (using a singleton)
- limiting
maxConnectionsPerHostlike this:final _client IOClient(HttpClient()..maxConnectionsPerHost = 1);
I'm not sure what effects the fix will have in normal operations. Also not sure when to close the client now.
From what I understand requests will now complete sequentially, but each request will be faster because the Client reuses the connection (?).
Are there additional error cases to be handled when reusing the Client?this issue have a solution? already 3 years since the post, flutter tim not fix it?
Reacted by Jens Christensen and SalsabeelaDoes this issue have a solution?
Hi, the original issue reported by @Gnpiwano was related to some legacy TLS behavior with a specific Rabobank test server and a fix is available.
For anyone with a different HTTP problem, could you please create a new issue? If the issue is with the
dart:ioHttpClientclass, could you please file an issue with the Dart SDK.- addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Aug 16, 2022 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Aug 30, 2022



Steps to Reproduce
execute following line:
The same call works using URLSession and postman but when using the http flutter package it crashes.
output
example application
flutter analyze
flutter doctor
verbose