Skip to content

Intermittent or no connection established to SQL Server #11804

Closed

Description

@Spectre-007

#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 : 

Activity

  1. added
    Issue-Question
    on Feb 7, 2020
  2. Spectre-007 commented on Feb 17, 2020

    @Spectre-007
    Author

    Did I do something wrong with the initial issue report?

  3. mklement0 commented on Feb 18, 2020

    @mklement0
    Contributor

    Your problem sounds like it may be specific to your environment as opposed to exhibiting a problem with PowerShell itself - only the latter issues should be reported here.

    Perhaps the "Support" link on the new-issue page (https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md) may have given you the idea that posting a support question here is appropriate.

    I agree that the information there is misleading, which has been pointed out before (/cc Steve Lee (@SteveL-MSFT)).

    Here's the relevant information:


    If you believe that you've found a problem with PowerShell itself and have reproducible steps to demonstrate it:

    Otherwise, do not post here and instead ask the community for support:

    • Slack and Discord Community Chat - interactive chat with other PowerShell enthusiasts. Both Slack and Discord are bridged via a bot and can seamlessly talk to each other.

    • StackOverflow.com and PowerShell.org Forum - search or post new general PowerShell usage questions

    See also: the official support lifecycle and policy.

    GitHub
    PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
  4. added
    Resolution-Answered
    on May 8, 2020
  5. ghost closed this as completedon May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-Answered

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions