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

Cannot authenticate to Sql Server 2008 - post-login phase timeout #4702

Closed
scott-martin opened this issue Mar 4, 2016 · 6 comments
Closed

Comments

@scott-martin
Copy link

Using the coreclr on ubuntu I am unable to authenticate to a Sql Server 2008 instance. I experience the same error every time on different machines, in fact I have been for several months now. I am able to connect to Sql Server 2012 and up fine. Also when running our application in a Windows environment it is able to connect to 2008. The problem only happens when using coreclr on linux.

fail: Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler[1]
      An exception occurred in the database while iterating the results of a query.
      System.Data.SqlClient.SqlException: Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=381; handshake=693; [Login] initialization=4; authentication=21; [Post-Login] complete=13030;  ---> System.ComponentModel.Win32Exception: Unknown error 258
         --- End of inner exception stack trace ---
         at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
         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.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
         at System.Data.SqlClient.SqlConnection.Open()
         at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()
         at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
         at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
         at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__27`1.MoveNext()
         at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__27`1.MoveNext()
         at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
         at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
         at lambda_method(Closure , QueryContext )
         at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_1`1.<CompileQuery>b__1(QueryContext qc)
      ClientConnectionId:ad256c7f-c9fa-4288-83a5-69b0f9d77d7d
      Error Number:-2,State:0,Class:11

Here is the relevant portion of my Startup.cs file

var connection = Configuration["Data:DefaultConnection:ConnectionString"];
services
    .AddEntityFramework()
    .AddSqlServer()
    .AddDbContext<DatabaseContext>(opts =>
    {
        opts.UseSqlServer(connection);                    
    });

The connection string looks like so:

"server=sql.mydomain.com;Database=QA;User Id=myuserid;Password=mypassword"

Obviously upgrading our Sql Server version would be nice, but it's not really possible at the moment. Can anyone offer any guidance on this issue? Thanks!

@natemcmaster
Copy link
Contributor

cc @saurabh500 does this look like any known issues in System.Data.SqlClient?

@scott-martin
Copy link
Author

@natemcmaster Is that the more appropriate place to post this issue?

@rowanmiller
Copy link
Contributor

SqlClient is part of the https://github.com/dotnet/corefx project. I'm assuming this would still occur if you took EF out of the mix and just tried connecting with SqlConnection (any chance you could verify that?).

@scott-martin
Copy link
Author

Looks like this might be my issue: https://github.com/dotnet/corefx/issues/6467. I'll post an update once I investigate further.

@scott-martin
Copy link
Author

https://github.com/dotnet/corefx/issues/6467 was the issue.

We were running Sql Server 2008 R2 without any service pack updates. Updating to service pack 3 fixed the issue.

@RickyLin
Copy link
Contributor

The same issue was fixed in Sql Server 2008 by installing service pack 4.

Microsoft SQL Server 2008 (SP4) - 10.0.6000.29 (X64)

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants