Repository navigation
http: Unhandled Exception: Connection closed before full header was received #41573
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consoledependency: dartDart team may need to help usDart team may need to help usdependency: dart:ioIssue in 'dart:io' libraryIssue in 'dart:io' libraryengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 1.24Found to occur in 1.24Found to occur in 1.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
execute following line:
final response = await http.get("https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts");
The same call works using URLSession and postman but when using the http flutter package it crashes.
output
Performing hot restart...
Syncing files to device iPhone van Guus...
Restarted application in 1,089ms.
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Connection closed before full header was received
#0 IOClient.send (package:http/src/io_client.dart:65:7)
<asynchronous suspension>
#1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:169:38)
<asynchronous suspension>
#2 BaseClient.get (package:http/src/base_client.dart:32:7)
#3 get.<anonymous closure> (package:http/http.dart:46:36)
#4 _withClient (package:http/http.dart:166:20)
<asynchronous suspension>
#5 get (package:http/http.dart:46:5)
#6 example (package:back_animation_ios/main.dart:12:26)
<asynchronous suspension>
#7 main (package:back_animation_ios/main.dart:8:2)
#8 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:231:25)
#9 _rootRun (dart:async/zone.dart:1124:13)
#10 _CustomZone.run (dart:async/zone.dart:1021:19)
#11 _runZoned (dart:async/zone.dart:1516:10)
#12 runZoned (dart:async/zone.dart:1500:12)
#13 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:223:5)
#14 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
#15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
example application
void main() {
example();
}
void example() async {
final response = await http.get("https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts");
print(response.body);
}
flutter analyze
Analyzing back_animation_ios...
No issues found! (ran in 1.5s)
flutter doctor
[✓] Flutter (Channel master, v1.10.7-pre.73, on Mac OS X 10.14.6 18G95, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.38.1)
[✓] Connected device (2 available)
verbose
[ +15 ms] executing: [/Users/guusiwanow/Developer/installations/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +25 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] 67b5bdf99b19e5f04bae5fb82af91aa695fbfbb9
[ ] executing: [/Users/guusiwanow/Developer/installations/flutter/] git describe --match v*.*.* --first-parent --long --tags
[ +21 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[ ] v1.10.6-73-g67b5bdf99
[ +6 ms] executing: [/Users/guusiwanow/Developer/installations/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +8 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/master
[ ] executing: [/Users/guusiwanow/Developer/installations/flutter/] git ls-remote --get-url origin
[ +8 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +46 ms] executing: [/Users/guusiwanow/Developer/installations/flutter/] git rev-parse --abbrev-ref HEAD
[ +9 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] master
[ +4 ms] executing: sw_vers -productName
[ +13 ms] Exit code 0 from: sw_vers -productName
[ ] Mac OS X
[ ] executing: sw_vers -productVersion
[ +14 ms] Exit code 0 from: sw_vers -productVersion
[ ] 10.14.6
[ ] executing: sw_vers -buildVersion
[ +14 ms] Exit code 0 from: sw_vers -buildVersion
[ ] 18G95
[ +12 ms] executing: /usr/bin/xcode-select --print-path
[ +11 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[ ] /Applications/Xcode.app/Contents/Developer
[ ] executing: /usr/bin/xcodebuild -version
[ +92 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[ ] Xcode 10.3
Build version 10G8
[ +46 ms] executing: /Users/guusiwanow/Library/Android/sdk/platform-tools/adb devices -l
[ +5 ms] Exit code 0 from: /Users/guusiwanow/Library/Android/sdk/platform-tools/adb devices -l
[ ] List of devices attached
[ +9 ms] executing: /Users/guusiwanow/Developer/installations/flutter/bin/cache/artifacts/libimobiledevice/idevice_id -h
[ +181 ms] /usr/bin/xcrun simctl list --json devices
[ +174 ms] More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.
[ +4 ms] iPhone van Guus • 00008020-000038423650003A • ios • iOS 12.4.1
[ ] iPhone Xʀ • 48D7954D-68A0-43CC-89F0-C04010341FA6 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)
[ +8 ms] "flutter run" took 605ms.
#0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1 RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:276:7)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:510:11)
<asynchronous suspension>
#3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:452:33)
<asynchronous suspension>
#4 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:157:29)
<asynchronous suspension>
#5 _rootRun (dart:async/zone.dart:1124:13)
#6 _CustomZone.run (dart:async/zone.dart:1021:19)
#7 _runZoned (dart:async/zone.dart:1516:10)
#8 runZoned (dart:async/zone.dart:1463:12)
#9 AppContext.run (package:flutter_tools/src/base/context.dart:156:18)
<asynchronous suspension>
#10 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:442:20)
#11 CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#12 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:416:21)
<asynchronous suspension>
#13 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:157:29)
<asynchronous suspension>
#14 _rootRun (dart:async/zone.dart:1124:13)
#15 _CustomZone.run (dart:async/zone.dart:1021:19)
#16 _runZoned (dart:async/zone.dart:1516:10)
#17 runZoned (dart:async/zone.dart:1463:12)
#18 AppContext.run (package:flutter_tools/src/base/context.dart:156:18)
<asynchronous suspension>
#19 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:367:19)
<asynchronous suspension>
#20 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#21 new Future.sync (dart:async/future.dart:224:31)
#22 CommandRunner.run (package:args/command_runner.dart:112:14)
#23 FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:251:18)
#24 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:63:22)
<asynchronous suspension>
#25 _rootRun (dart:async/zone.dart:1124:13)
#26 _CustomZone.run (dart:async/zone.dart:1021:19)
#27 _runZoned (dart:async/zone.dart:1516:10)
#28 runZoned (dart:async/zone.dart:1500:12)
#29 run.<anonymous closure> (package:flutter_tools/runner.dart:61:18)
<asynchronous suspension>
#30 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:157:29)
<asynchronous suspension>
#31 _rootRun (dart:async/zone.dart:1124:13)
#32 _CustomZone.run (dart:async/zone.dart:1021:19)
#33 _runZoned (dart:async/zone.dart:1516:10)
#34 runZoned (dart:async/zone.dart:1463:12)
#35 AppContext.run (package:flutter_tools/src/base/context.dart:156:18)
<asynchronous suspension>
#36 runInContext (package:flutter_tools/src/context_runner.dart:63:24)
<asynchronous suspension>
#37 run (package:flutter_tools/runner.dart:50:10)
#38 main (package:flutter_tools/executable.dart:65:9)
<asynchronous suspension>
#39 main (file:///Users/guusiwanow/Developer/installations/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#41 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consoledependency: dartDart team may need to help usDart team may need to help usdependency: dart:ioIssue in 'dart:io' libraryIssue in 'dart:io' libraryengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 1.24Found to occur in 1.24Found to occur in 1.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Activity
Gnpiwano commentedon Sep 29, 2019
Issue exist on Master and stable.
BondarenkoStas commentedon 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?
Gnpiwano commentedon 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.
Gnpiwano commentedon 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.
cakesoft-shailesh commentedon Nov 12, 2019
Hi @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].
cpatricio23 commentedon Dec 9, 2019
Does anyone fix this issue? What did you do?
Gnpiwano commentedon Dec 9, 2019
@HumbleCarl ,
I fixed it for now by creating a http channel and do the http request natively and then return the response.
mohamedashraf8850 commentedon Dec 16, 2019
How ?
Gnpiwano commentedon Dec 16, 2019
@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:)
VladyslavBondarenko commentedon Jan 20, 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 you
91 remaining items
Justus-M commentedon Apr 28, 2022
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.
lokingwei commentedon Jun 1, 2022
I 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.The cipher which throw the exception:


The cipher that's work:

Abdelaty commentedon Jun 8, 2022
I'm having the same issue on real devices.
brianquinlan commentedon Jun 21, 2022
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.
dewbambs commentedon Jul 1, 2022
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): ----------------------------------------------------
rustonaut commentedon Jul 19, 2022
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.
stsc3000 commentedon Jul 28, 2022
We're seeing a lot of these when using the Android 13 Beta 4.1 (emulated).
It does no longer occur when
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?
eggyot commentedon Aug 10, 2022
this issue have a solution? already 3 years since the post, flutter tim not fix it?
SalsabeelaHasan commentedon Aug 14, 2022
Does this issue have a solution?
brianquinlan commentedon Aug 15, 2022
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.github-actions commentedon Aug 30, 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.