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

Flutter should respect proxy settings on Windows during Dart SDK download #10903

Open
felix-hubo opened this issue Jun 22, 2017 · 14 comments
Open
Labels
P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@felix-hubo
Copy link

felix-hubo commented Jun 22, 2017

I met errors when running flutter doctor. It's related with proxy settings.

Flutter Doctor

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\CNFEHU1>flutter doctor
Checking Dart SDK version...
Downloading Dart SDK 1.24.0-dev.6.7...
Start-BitsTransfer : HTTP status 407: Proxy authentication is required.
At C:\Users\CNFEHU1\Documents\GitHub\flutter\bin\internal\update_dart_sdk.ps1:4
4 char:19
+ Start-BitsTransfer <<<<  -Source $dartSdkUrl -Destination $dartSdkZip
    + CategoryInfo          : InvalidOperation: (:) [Start-BitsTransfer], Exce
   ption
    + FullyQualifiedErrorId : StartBitsTransferCOMException,Microsoft.Backgrou
   ndIntelligentTransfer.Management.NewBitsTransferCommand

Error: Unable to update Dart SDK. Retrying...
@eseidelGoogle
Copy link
Contributor

@goderbauer might know. Looks like it's not using your network proxy correctly?

@eseidelGoogle eseidelGoogle added the platform-windows Building on or for Windows specifically label Jun 22, 2017
@goderbauer
Copy link
Member

If your proxy requires manual configuration, we currently offer no way to do that for the initial download of the Dart SDK. We should probably do what pub does and respect the http_proxy env variable, if present (see https://www.dartlang.org/tools/pub/troubleshoot#pub-get-fails-from-behind-a-corporate-firewall). Linux's curl util automatically uses that env. On Windows, we've to teach BitsTransfer how to use it it seems...

If you are feeling adventures: This is the line where we use Windows's BitsTransfer to download the SDK: https://github.com/flutter/flutter/blob/master/bin/internal/update_dart_sdk.ps1#L44. And this is the documentation describing the proxy settings for BitsTransfer: https://technet.microsoft.com/en-us/library/dd819420.aspx. If you attempt this, let me know what settings were required to make it work.

@goderbauer goderbauer changed the title ERRORs when running flutter doctor Flutter should have respect proxy settings on Windows during Dart SDK download Jun 22, 2017
@goderbauer goderbauer changed the title Flutter should have respect proxy settings on Windows during Dart SDK download Flutter should respect proxy settings on Windows during Dart SDK download Jun 22, 2017
@wangyun
Copy link

wangyun commented Feb 24, 2018

I add -ProxyUsage Override -ProxyList 192.168.0.118:1080 to:
Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip
and it works.

@jAwAno
Copy link

jAwAno commented Mar 6, 2018

We also need to get over a proxy and it has BASIC authentication.
and we alredy have "http_proxy" variable at envitronment as this format

http://username:pass@proxyHost:port

so I added this codes for resolve problem at update_dart_sdk.ps1 and it works fine

If($httpProxy = ([System.Uri] $env:http_proxy)){
    $proxyUserInfo = $httpProxy.UserInfo.Split(":")
    $proxyPass = ConvertTo-SecureString $proxyUserInfo[1] -AsPlainText -Force
    $proxyCredential = New-Object System.Management.Automation.PSCredential ($proxyUserInfo[0], $proxyPass)
    
    Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip -ProxyUsage Override -ProxyList ($httpProxy.Host + ":" + $httpProxy.Port) -ProxyCredential $proxyCredential -ProxyAuthentication Basic    
}Else{
    Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip
}

@goderbauer
Copy link
Member

@jAwAno would you be willing to send us a pull request with that change?

@igitur
Copy link

igitur commented Mar 6, 2018

@goderbauer Hang on. That change might break a lot of other users' setup. Start-BitsTransfer is supposed to honor the Windows system proxy settings, right?

@goderbauer
Copy link
Member

This would only change things for users, that have $env:http_proxy set explicitly, no?

jAwAno added a commit to jAwAno/flutter that referenced this issue Mar 7, 2018
…y info from that and use (flutter#10903)

If windows machine behind a proxy and already has environment variable "http_proxy" as below format
http://username:pass@proxyHost:port
then use those information for get over proxy when running flutter doctor.
@jAwAno
Copy link

jAwAno commented Mar 7, 2018

@goderbauer
I sent a pull request .
and Yes this change will only affect for user who defined http_proxy at environment variables.

@igitur
Copy link

igitur commented Mar 7, 2018

@goderbauer True, but I'm one of those users who has http_proxy set, for very specific purposes. And a lot of times, clients would fail to use that because our proxy requires NTLM authentication. I still believe that since Start-BitsTransfer is supposed to honor the Windows system proxy settings, we should look into why that is not happening for the user, instead of building in workarounds that might cause more problems.

One guess is that Start-BitsTransfer could be failing because of missing or expired credentials. In that case the -UseStoredCredential Proxy switch might help. (@jAwAno , please rather that instead of the http_proxy workaround).

Let's not be hasty about this. Understand the cause before trying to fix it.

@igitur
Copy link

igitur commented Mar 7, 2018

@jAwAno Please confirm whether your Windows proxy settings are populated correctly.

@jAwAno
Copy link

jAwAno commented Mar 7, 2018

@igitur Ok I'll check my setting again , and actually you're right fixing authentication method to BASIC is bad way . hm I'll find some other way

@codeitbhanu
Copy link

codeitbhanu commented Mar 23, 2018

This Worked For Me:

Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip -ProxyAuthentication Basic -ProxyUsage Override -ProxyCredential YOUR_USERNAME -ProxyList IP_ADDRESS:PORT_NO

@zoechi zoechi added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 4, 2018
@zoechi zoechi added this to the Goals milestone Dec 4, 2018
@sam17896
Copy link

This is still an issue in December 2019.

@jmagman jmagman added this to Awaiting triage in Tools - Windows review Jan 10, 2020
@christopherfujino christopherfujino moved this from Awaiting triage to Engineer reviewed in Tools - Windows review Jan 16, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@kf6gpe kf6gpe removed this from the Goals milestone Jun 2, 2020
@Hixie Hixie removed this from the Goals milestone Jun 2, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@plato79
Copy link

plato79 commented Apr 20, 2021

We also need to get over a proxy and it has BASIC authentication.
and we alredy have "http_proxy" variable at envitronment as this format

http://username:pass@proxyHost:port

so I added this codes for resolve problem at update_dart_sdk.ps1 and it works fine

If($httpProxy = ([System.Uri] $env:http_proxy)){
    $proxyUserInfo = $httpProxy.UserInfo.Split(":")
    $proxyPass = ConvertTo-SecureString $proxyUserInfo[1] -AsPlainText -Force
    $proxyCredential = New-Object System.Management.Automation.PSCredential ($proxyUserInfo[0], $proxyPass)
    
    Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip -ProxyUsage Override -ProxyList ($httpProxy.Host + ":" + $httpProxy.Port) -ProxyCredential $proxyCredential -ProxyAuthentication Basic    
}Else{
    Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip
}

While the code above is good, as @jAwAno said, authentication could be a problem. I'm using CNTLM to forward NTLM proxy to HTTP proxy and use it for git. Although I'm not using any authentication so lines with authentication actually is a bit problem for me. So I think we need to check if there's authentication ( user/password ) in proxy line or not. If it's not available we need to remove -ProxyCredential and -ProxyAuthentication parameters.

@flutter-triage-bot flutter-triage-bot bot added team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
Tools - Windows review
  
Engineer reviewed
Development

No branches or pull requests