Closed
Description
#Steps to reproduce
Create a connection to a SQL Server and run a command from the SQLserver module
$connectionString = "Server=<servername>,14481;database=hoclusters;Integrated Security=True;Persist Security Info=True;User ID=$user;Password=$pwd"
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $connectionString
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.Connection = $SqlConnection
$SqlCmd.CommandTimeout = 0
invoke-sqlcmd -serverinstance '<servername>,14481' -database 'master' -query "select @@servername" -QueryTimeout 60
Expected behavior
invoke-sqlcmd command to return server name after successful connection
Actual behavior
A connection is established but the pre-login handshake times out
Environment data
Exception :
Type : Microsoft.SqlServer.Management.Common.ConnectionFailureException
TargetSite :
Name : Connect
DeclaringType : Microsoft.SqlServer.Management.Common.ConnectionManager
MemberType : Method
Module : Microsoft.SqlServer.ConnectionInfo.dll
StackTrace :
at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
at Microsoft.SqlServer.Management.PowerShell.SmoCmdlet.ConnectToServer(String instance, PSCredential cred, Nullable`1 timeout)
at Microsoft.SqlServer.Management.PowerShell.SmoContextSensitiveTargetedWithServerInstanceCmdlet`1.ResolveTargets()+MoveNext()
Message : Failed to connect to server <servername>,14481.
InnerException :
Type : System.Data.SqlClient.SqlException
Errors :
Source : Core .Net SqlClient Data Provider
Number : 258
Class : 20
Server : <servername>,14481
Message : A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error:
0 - The wait operation timed out.)
ClientConnectionId : d95f684b-ab07-4bb7-9f0f-cfa4c9517b1e
Class : 20
Number : 258
Server : <servername>,14481
Source : Core .Net SqlClient Data Provider
ErrorCode : -2146232060
TargetSite : Void .ctor(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential,
System.Object, System.String, System.Security.SecureString, Boolean, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SessionData, Boolean, System.String)
StackTrace :
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object
providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData
reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool
pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean
onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1
retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry,
DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect()
at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
Message : A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider,
error: 0 - The wait operation timed out.)
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : System.ComponentModel.Win32Exception
NativeErrorCode : 258
ErrorCode : -2147467259
Message : The wait operation timed out.
HResult : -2147467259
HResult : -2146232060
Source : Microsoft.SqlServer.ConnectionInfo
HResult : -2146233087
TargetObject : <servername>,14481
CategoryInfo : ObjectNotFound: (<servername>,14481:String) [Read-SqlTableData], ConnectionFailureException
FullyQualifiedErrorId : ConnectionToServerFailed,Microsoft.SqlServer.Management.PowerShell.ReadSqlTableData
InvocationInfo :
MyCommand : Read-SqlTableData
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 11
Line : Read-SqlTableData -ServerInstance '<servername>,14481' -DatabaseName ho_cpu_wait -SchemaName "dbo" -TableName "table1"
PositionMessage : At line:1 char:1
+ Read-SqlTableData -ServerInstance '<servername>. …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Read-SqlTableData
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :