Friday, June 5, 2020

The underlying connection was closed: An unexpected error occurred on a send




Attempting to use VMware vSphere PowerCLI's Connect-VIServer to a vCenter instance fails with: "The underlying connection was closed: An unexpected error occurred on a send." 

Problem

You have VMware vSphere PowerCLI version 5.1.0.4977 installed:









 


using the Connect-VIServer cmdlet but it immediately fails with:
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer vCenter.contoso.local
Connect-VIServer : 2/22/2019 11:41:37 AM Connect-VIServer The underlying connection was closed: An unexpected error
occurred on a send.
At line:1 char:1
+ Connect-VIServer vCenter.contoso.local
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], ViError
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_WebException,VMware.VimAutomation.ViCore.Cmdl
ets.Commands.ConnectVIServer




PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>


 


Solution
The reason why this error is thrown is because vCenter 6.7 only has TLS 1.2 enabled while TLS 1.0 and 1.1 is disabled by default so the older PowerCLI version installed, which attempts to connect via a one of the lower TLS versions will fail. The proper method of resolving this issue is to upgrade the old PowerCLI version to the latest one with the cmdlet Install-Module -Name VMware.PowerCLI

Another way type below command
#FORCE POWERCLI TO USE TLS1.2
=============================
PowerCLI E:\git> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12



No comments:

Post a Comment

NSX-V vs NSX-T – Basic Comparison

                                            NSX-V                      NSX-T  Tight integration with vSphere Yes No Works without vCenter No...