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

Intermittent or no connection established to SQL Server #11804

Closed
Spectre-007 opened this issue Feb 7, 2020 · 3 comments
Closed

Intermittent or no connection established to SQL Server #11804

Spectre-007 opened this issue Feb 7, 2020 · 3 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.

Comments

@Spectre-007
Copy link

Spectre-007 commented Feb 7, 2020

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

@Spectre-007 Spectre-007 added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Feb 7, 2020
@Spectre-007
Copy link
Author

Did I do something wrong with the initial issue report?

@mklement0
Copy link
Contributor

mklement0 commented Feb 18, 2020

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 @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.

@ghost
Copy link

ghost commented May 9, 2020

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed May 9, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

3 participants