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

Connection closed before full header was received when pub publish using https proxy #2658

Closed
liudonghua123 opened this issue Sep 18, 2020 · 4 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@liudonghua123
Copy link

Environment

  • pub version or flutter pub version: Pub 2.9.3
  • OS version: Microsoft Windows [Version 10.0.19041.508]
  • Are you using the Chinese community mirror or a corporate firewall? Yes

Problem

I want to publish a package, because I am in some restricted network environment. I can manage to connect to the outside network using a https proxy via extension in Chrome. I also set http_proxy/https_proxy and test it ok using curl (I need to add --proxy-insecure option or I will get network error issue). But when I try to execute pub publish, I got Connection closed before full header was received error.

Expected behavior

pub publish works on the existed https proxy.

Actual behavior

network error

--trace output

Microsoft Windows [Version 10.0.19041.508]
(c) 2020 Microsoft Corporation. All rights reserved.

D:\code\dart\simple_throttle_debounce>set http_proxy=https://usa.cn-cloudflare.com:443

D:\code\dart\simple_throttle_debounce>set https_proxy=https://usa.cn-cloudflare.com:443

D:\code\dart\simple_throttle_debounce>curl --proxy-insecure cip.cc
IP      : 185.152.67.14
地址    : 美国  加利福尼亚州  洛杉矶
运营商  : cdn77.com

数据二  : 美国 | 加利福尼亚州洛杉矶CDN77节点

数据三  : 英国

URL     : http://www.cip.cc/185.152.67.14

D:\code\dart\simple_throttle_debounce>pub publish
Publishing simple_throttle_debounce 0.0.1 to https://pub.flutter-io.cn:
|-- .gitignore
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- analysis_options.yaml
|-- example
|   '-- simple_throttle_debounce_example.dart
|-- lib
|   |-- simple_throttle_debounce.dart
|   '-- src
|       |-- simple_throttle_debounce_base.dart
|       '-- var_args_function.dart
|-- pubspec.yaml
'-- test
    '-- simple_throttle_debounce_test.dart
Connection closed before full header was received

D:\code\dart\simple_throttle_debounce>

Here is the verbose log

verbose
D:\code\dart\simple_throttle_debounce>pub --verbose publish                  
FINE: Pub 2.9.3
IO  : Spawning "cmd /c ver" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished ver. Exit code 0.
    | stdout:
    | |
    | | Microsoft Windows [Version 10.0.19041.508]
    | Nothing output on stderr.
IO  : Spawning "cmd /c git --version" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | git version 2.16.1.windows.4
    | Nothing output on stderr.
FINE: Determined git command git.
IO  : Spawning "cmd /c git check-ignore --quiet ." in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 1.
    | Nothing output on stdout.
    | Nothing output on stderr.
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
FINE: Archiving and publishing simple_throttle_debounce 0.0.1 (.).
MSG : Publishing simple_throttle_debounce 0.0.1 to https://pub.flutter-io.cn:
    | |-- .gitignore
    | |-- CHANGELOG.md
    | |-- LICENSE
    | |-- README.md
    | |-- analysis_options.yaml
    | |-- example
    | |   '-- simple_throttle_debounce_example.dart
    | |-- lib
    | |   |-- simple_throttle_debounce.dart
    | |   '-- src
    | |       |-- simple_throttle_debounce_base.dart
    | |       '-- var_args_function.dart
    | |-- pubspec.yaml
    | |-- test
    | |   '-- simple_throttle_debounce_test.dart
    | '-- verbose_log.txt
FINE: Creating .tar.gz stream containing:
    | .\verbose_log.txt
    | .\.gitignore
    | .\CHANGELOG.md
    | .\LICENSE
    | .\README.md
    | .\analysis_options.yaml
    | .\example\simple_throttle_debounce_example.dart
    | .\lib\simple_throttle_debounce.dart
    | .\lib\src\simple_throttle_debounce_base.dart
    | .\lib\src\var_args_function.dart
    | .\pubspec.yaml
    | .\test\simple_throttle_debounce_test.dart
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
IO  : Reading binary file .\README.md.
IO  : Read 1114 bytes from .\README.md.
IO  : Spawning "cmd /c git ls-files --cached --others --exclude-standard" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished git. Exit code 0.
    | stdout:
    | | verbose_log.txt
    | | .gitignore
    | | CHANGELOG.md
    | | LICENSE
    | | README.md
    | | analysis_options.yaml
    | | example/simple_throttle_debounce_example.dart
    | | lib/simple_throttle_debounce.dart
    | | lib/src/simple_throttle_debounce_base.dart
    | | lib/src/var_args_function.dart
    | | pubspec.yaml
    | | test/simple_throttle_debounce_test.dart
    | Nothing output on stderr.
IO  : Reading binary file .\CHANGELOG.md.
IO  : Read 71 bytes from .\CHANGELOG.md.
IO  : Get versions from https://pub.flutter-io.cn/api/packages/simple_throttle_debounce.
IO  : HTTP GET https://pub.flutter-io.cn/api/packages/simple_throttle_debounce
    | Accept: application/vnd.pub.v2+json
    | user-agent: Dart pub 2.9.3
IO  : Created temp directory C:\Users\LIUD~1.H\AppData\Local\Temp\pub_4dcab561
IO  : Writing 286 characters to text file C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561\files.txt.
FINE: Contents:
    | verbose_log.txt
    | .gitignore
    | CHANGELOG.md
    | LICENSE
    | README.md
    | analysis_options.yaml
    | example\simple_throttle_debounce_example.dart
    | lib\simple_throttle_debounce.dart
    | lib\src\simple_throttle_debounce_base.dart
    | lib\src\var_args_function.dart
    | pubspec.yaml
    | test\simple_throttle_debounce_test.dart
IO  : Spawning "D:\apps\dart\dart-sdk\lib\_internal\pub\asset\7zip\7za.exe a -wD:\code\dart\simple_throttle_debounce\. C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561\intermediate.tar @C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561\files.txt" in D:\code\dart\simple_throttle_debounce\.
IO  : Finished D:\apps\dart\dart-sdk\lib\_internal\pub\asset\7zip\7za.exe. Exit code 0.
    | stdout:
    | |
    | | 7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
    | | Scanning
    | | 
    | | Creating archive C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561\intermediate.tar
    | |
    | | Compressing  .gitignore
    | | Compressing  analysis_options.yaml
    | | Compressing  CHANGELOG.md
    | | Compressing  example\simple_throttle_debounce_example.dart
    | | Compressing  lib\simple_throttle_debounce.dart
    | | Compressing  lib\src\simple_throttle_debounce_base.dart
    | | Compressing  lib\src\var_args_function.dart
    | | Compressing  LICENSE
    | | Compressing  pubspec.yaml
    | | Compressing  README.md
    | | Compressing  test\simple_throttle_debounce_test.dart
    | | Compressing  verbose_log.txt
    | |
    | | Everything is Ok
    | Nothing output on stderr.
IO  : Spawning "D:\apps\dart\dart-sdk\lib\_internal\pub\asset\7zip\7za.exe a unused -tgzip -so C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561\intermediate.tar" in D:\code\dart\simple_throttle_debounce\.  
IO  : Deleting directory C:\Users\Liu.D.H\AppData\Local\Temp\pub_4dcab561.
ERR : Connection closed before full header was received
FINE: Exception type: ClientException
FINE: package:pub/src/source/hosted.dart 439:7    BoundHostedSource._throwFriendlyError
    | package:pub/src/source/hosted.dart 190:7    BoundHostedSource._fetchVersions
    | ===== asynchronous gap ===========================
    | dart:async                                  Future.catchError
    | package:pub/src/utils.dart 113:52           captureErrors.wrappedCallback
    | package:stack_trace                         Chain.capture
    | package:pub/src/utils.dart 126:11           captureErrors
    | package:pub/src/command_runner.dart 193:13  PubCommandRunner.runCommand
    | dart:async                                  _completeOnAsyncReturn
    | package:pub/src/command_runner.dart         PubCommandRunner._validatePlatform
    | dart:async                                  _completeOnAsyncReturn
    | package:pool/pool.dart                      Pool.withResource
    | dart:async                                  _completeOnAsyncReturn
    | package:pub/src/io.dart                     runProcess.<fn>

D:\code\dart\simple_throttle_debounce>
@sigurdm
Copy link
Contributor

sigurdm commented Sep 16, 2021

@jonasfj what do you think - should we take $http_proxy into account? Should this happen at the dart:io level?

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Sep 16, 2021
@isoos
Copy link
Contributor

isoos commented Sep 16, 2021

Also a reference of how curl uses environment variables: https://everything.curl.dev/usingcurl/proxies#proxy-environment-variables

@jonasfj
Copy link
Member

jonasfj commented Sep 20, 2021

Isn't there already support for this:
https://dart.dev/tools/pub/troubleshoot#pub-get-fails-from-behind-a-corporate-firewall

--proxy-insecure

But if you want to ignore HTTPS certificates you'll need to add them to your system. Recent versions of Dart have patched to load custom certificates from the operating system.

We do not offer a --proxy-insecure option, and I think our decision that we shall not offer such option. If you trust a proxy add its certificate to the system.


Note. it's entirely possible that we update pub to have tests to ensure that custom certificates and https_proxy actually works as expected.

@jonasfj jonasfj closed this as completed Sep 20, 2021
@jonasfj
Copy link
Member

jonasfj commented Sep 20, 2021

Filed #3127 for setting up automated testing for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants