Docs: Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error occurred on a send."

Created on 7 Aug 2018  Â·  9Comments  Â·  Source: dotnet/docs

Hi,
Since yesterday, at least, we are getting this error when running (New-Object System.Net.WebClient).DownloadString("https://dot.net/v1/dotnet-install.ps1") > dotnet-install.ps1 or wget https://dot.net/v1/dotnet-install.ps1 from a docker container under microsoft/dotnet-framework:4.7.2-sdk, this has also been reproduced under a current Windows 10 Desktop install.

Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error occurred on a send."
At line:1 char:1
+ (New-Object System.Net.WebClient).DownloadString("https://dot.net/v1/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

Accessing from a browser works as expected.
Will this be fixed. What can we do in the meantime?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - .NET Core Guide Technology - CLI dotnet-corprod product-feedback

Most helpful comment

In my experience this is because of the combination of TLS 1.2 requirement on the website and PowerShell. This explains: https://www.codyhosterman.com/2016/06/force-the-invoke-restmethod-powershell-cmdlet-to-use-tls-1-2/ And this sample above shows how to do this from PowerShell: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"

All 9 comments

In my experience this is because of the combination of TLS 1.2 requirement on the website and PowerShell. This explains: https://www.codyhosterman.com/2016/06/force-the-invoke-restmethod-powershell-cmdlet-to-use-tls-1-2/ And this sample above shows how to do this from PowerShell: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"

I see, thank you. We have used a compiled curl in the meantime. Do you think Powershell will upgrade to 1.2 as default in the following months? The dotnet-install.ps1 script in itself does not seem to fail currently.

@KathleenDollard @johnbeisner can you please comment?

@johnbeisner Will this continue to be a problem going forward?

Met with @johnbeisner today about this. There's not much we can do since this is a constraint from the environment you run the script. Hopefully the workaround to force PS to use TLS 1.2 provided by @MikkelHegn can help in this scenario.

In my experience this is because of the combination of TLS 1.2 requirement on the website and PowerShell. This explains: https://www.codyhosterman.com/2016/06/force-the-invoke-restmethod-powershell-cmdlet-to-use-tls-1-2/ And this sample above shows how to do this from PowerShell: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"

Thanks ,it's working

Even without TLS using https, I get this error. Anyone faced the same?

@yehgdotnet me too the problem i am facing is

The splatting operator '@' cannot be used to reference variables in an expression. '@powershell' can be used only as an
 argument to a command. To reference variables in an expression use '$powershell'.
At line:1 char:12
+ @powershell <<<<  -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [N
et.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps
1'))) <additional install-script args>"@powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePoint
Manager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https
://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
    + CategoryInfo          : ParserError: (powershell:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : SplattingNotPermitted
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stjepan picture stjepan  Â·  3Comments

sdmaclea picture sdmaclea  Â·  3Comments

tswett picture tswett  Â·  3Comments

sebagomez picture sebagomez  Â·  3Comments

LJ9999 picture LJ9999  Â·  3Comments