runtime icon indicating copy to clipboard operation
runtime copied to clipboard

A connection was successfully established with the server, but then an error occurred during the login process

Open sady4850 opened this issue 10 years ago • 10 comments

dotnet 1.0.0-beta-001528

Runtime Environment:

OS Name: ubuntu OS Version: 15.04 OS Platform: Linux Runtime Id: ubuntu.15.04-x64

System.Data.SqlClient 4.0.0-rc3-23823

ConnectionString : data source=server,port;Initial Catalog=XXXXXXXX;Integrated Security=False;User ID=sa;Password=XXXX;Connect Timeout=150;Encrypt=False

The same console app works on Windows.

Opening SqlConnection results in the following SqlException:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.IO.IOException: Unable to read data from the transport connection: Unknown error 10054. ---> System.Net.Sockets.SocketException: Unknown error 10054

at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)  
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

--- End of inner exception stack trace ---   
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)   
at System.Data.SqlClient.SNI.SNITCPHandle.Receive(SNIPacket& packet, Int32 timeoutInMilliseconds)   
--- 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 ConsoleApplication.Program.Main(String[] args)

sady4850 avatar Feb 26 '16 13:02 sady4850

@saurabh500 @corivera @kkurni

joshfree avatar Feb 27 '16 03:02 joshfree

@sady4850 is this an Azure SQL server? Also is this one off or a consistent failure?

saurabh500 avatar Feb 27 '16 03:02 saurabh500

@saurabh500

select @@VERSION

Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)

This is 100% consistent

sady4850 avatar Feb 27 '16 18:02 sady4850

Thanks @sady4850

We will take a look.

saurabh500 avatar Feb 27 '16 18:02 saurabh500

@sady4850 it seems your issue is related with https://github.com/dotnet/corefx/issues/5187

Try to apply hotfix on your sql server https://support.microsoft.com/en-us/kb/2653857

----Quoted--- SQL Server 2008 R2 Service Pack 1

The fix for this issue was first released in Cumulative Update 6 for SQL Server 2008 R2 Service Pack 1. For more information about how to obtain this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base: 2679367 Cumulative Update package 6 for SQL Server 2008 R2 Service Pack 1 Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 2567616 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 Service Pack 1 was released

kkurni avatar Feb 27 '16 20:02 kkurni

@kkurni are you suspecting this to be the TLS issue?

saurabh500 avatar Feb 27 '16 20:02 saurabh500

Yes based on the sql server and it happened on ubuntu and the error message saying that unable to read data.

It most likely stuck when receiving those login bytes during login. The server doesnt response because open ssl split the bytes.

kkurni avatar Feb 27 '16 20:02 kkurni

@sady4850 would it be possible to apply this patch to the server and try connecting from linux again? Let us know.

saurabh500 avatar Feb 27 '16 21:02 saurabh500

@saurabh500 installing SP3 solved the problem, thanks

sady4850 avatar Feb 28 '16 13:02 sady4850

using Coreclr : 1.0.0-rc2-20221 coreclr x64

Ubuntu : 14.04 System.Data.SqlClient : 4.0.0-beta-23516

Connection String : SqlConnection connect = new SqlConnection("Server =XXXX; Trusted_Connection = False; User ID = XX; Password = XXXXXX; Initial Catalog = XXXX");

The Same Console App works on windows

Opening SqlServer results in the following exception

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - Attempt by method 'System.Data.SqlClient.SNI.SNITCPHandle..ctor(System.String, Int32, Int64, System.Object, Boolean)' to access method 'System.Net.Sockets.TcpClient.get_Client()' failed.) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) 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, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at Program.Main() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider) at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0() at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.Tasks.Task.Execute() ClientConnectionId:00000000-0000-0000-0000-000000000000

KeerthiBabu avatar Apr 07 '16 14:04 KeerthiBabu