-
Notifications
You must be signed in to change notification settings - Fork 292
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
Open connection issue on Linux #126
Comments
That is an odd server name in the connection string, maybe change to:
|
I tried your suggestion same result works on Windows but not Linux. |
Can you resolve the server name from the Linux box? |
Yes I use the same connection string with python pyodbc just adding the driver parameter which is not need with c# |
Well I was testing with SQL Server 2008 and switched to SQL Server 2016 and that works. Interestingly the Windows version of Microsoft.Data.SqlClient with both but the Linux version only works with 2016. |
@sjc1832 Have you checked with SQL Server 2012 by any chance? Since SQL Server 2008 and 2008 R2 are Out of Support, we wouldn't fix the driver to support them. If the issue happens with SQL Server 2012 as well (which is the oldest of supported SQL Servers) we can consider taking a deeper look. |
I have not checked 2012. |
I'm facing same issue - i.e. my dotnet core 3 preview8 application is running in Kubernetes cluster (on premise Linux container) which is trying to access remote MSSQL Server 2014 - but hung at connection.Open(). Connection string : "Data Source=10.150.109.140,1433;Initial Catalog=ReportServer;Connect Timeout=60;User ID=username;Password=password; Persist Security Info=False;Packet Size=4096" Docker images used : mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview8 & mcr.microsoft.com/dotnet/core/aspnet:3.0.0-preview8 |
Hi, The error we get in our logs is: System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. The connection string is: Application Name={appName};Server={host};User ID={id};Password={password};Database={dbname};Persist Security Info=false;Connection Lifetime=60 The machine has access to the sql box, if I role the code back to the .net core 2.2 version everything works fine. Its after upgrade to .netcore 3 it has stopped. The code that fails is simply The sql box is an RDS instance provided by AWS. The Engine version is 13.00.2164.0.v1. I dont seem to be able to see what version of sql server it is under the hood, but it looks like its 2016 (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_SQLServer.html) The EC2 box inside our ECS cluster is Amazon Linux AMI 2018.03.p x86_64 ECS HVM GP2 Docker Images used: |
Hi @lukebronts
Could you tell us the version of Microsoft.Data.SqlClient driver in use? Also please confirm SQL Server version from RDS cluster, by executing |
I have tried both 1.0.19269.1 and the current one in preview 1.1.0-preview1.19275.1. Both do not work. |
Do you have an update on this issue? Have you managed to find anything? Thanks |
Having the same issue Sql Server Version is 2016, running in Docker with netcore 3 using mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim |
@mgbee8 does it work for you if you use netcore 2.2? Also, can you try to use the latest Microsoft.Data.SqlClient? |
yes, I have the same issue using netcore 2.2 and Microsoft.Data.SqlClient |
@mgbee8 Same with us.
Maybe there is some relation to new client. |
Im having the same issue as @voroninp . I have a production stack in AWS working fine. My test stack times out connecting to RDS. Task running in fargate in private subnet of own vpc. I spend 4 hours with AWS support and proved that the network and security setup is correct. We could get powershell to connect to SQL ok. |
I spent hours yesterday trying everything to fix this issue and ended up finding that a TLS version mismatch caused the issue on my debian10 server. This is what brought me to this solution. Server version (not a container): Dotnet core version: APP#1 could not connect to SqlServer, same error as others in this thread :
APP#2: Could connect just fine. I edited the openssl.conf file and rebooted the server, problem solved. /etc/ssl/openssl.cnf
dotnetcore 3.1 app can now connect to SQL server just fine. Now to take a look at the settings on my SqlServer instance TLS 1.1 and 1.2 are both enabled Can someone explain to me the logic behind this fix ? I'm trying to understand if this is actually the fix or if it might have been something else. |
Hi @avboivin The exception you posted doesn't seem related to TLS Version change, but rebooting might have solved it since that would flush all open connections. Could you update Microsoft.Data.SqlClient version to 1.1.0 (with explicit package reference) and then confirm if the issue persists. If you have TLS 1.2 support enabled on Server, client supporting TLS1.2 protocol should be able to connect without any change needed to SSL Configurations. To know the TLS version in use, you can capture network traces with Wireshark, where you can see the TLS version in pre-login packets where Client and Server perform handshake. |
Hi @cheenamalhotra, I just tried uncommenting and rebooting and could reproduce the issue. Uncommented this line from /etc/ssl/openssl.cnf Commented the line from /etc/ssl/openssl.cnf again I've never used wireshark so if you can point me to a relevant tutorial I'd be inclined to try it but otherwise that's not something I'm willing to test right now. Thanks for the quick response ! |
You can always find online tutorials to use Wireshark, it's a bit tricky to get hands-on, but if you're not facing issues, you may not need to :) |
Thanks. It worked for me by adding single line in dockerfile because with dockerfile there is no need for explicit reboot:
Example dockerfile:
|
Hi @cheenamalhotra, I could reproduce the issue in mssql 2008 r2, but don't reproduce the issue in mssql 2012 |
I had this problem on RDS instance on AWS. Not sure what version is there. |
@feizeikesi @iarovyi |
I am also hitting this very issue. The specifics of my circumstance are: Client OS: Ubuntu 18.04 (WSL on Windows 10) It fails exactly the same as the original report:
Using a windows build of the exact same source from the exact same server does not hit this error. Using the linux build of this source against a SqlServer 2016 instance also does not hit this error. Given that this appears to be linux + SqlServer 2008 only, and the driver is not going to get updated for issues with 2008 due to EOL status, we will have to find a different workaround... |
We solved the same issue for SQL Sever 2008 R2 by installing SP3. |
@iarovyi Thanks for this. I just lost several days trying to figure out what I was doing wrong and then took me a while to find this thread. @cheenamalhotra I had this issue on MS SQL 2012 running exactly same stack as @iarovyi. If you need more details let me know. |
What is the Connection Timeout given? Try to update SQL Server 2008 to SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64) |
I'm experiencing the same issue using Microsoft.Data.SqlClient 1.1.1 connecting to SQL Server 2016. The sed command fixes it as a workaround for now, but it seems to be affecting newer SQL Server versions as well |
Dear all, I get same error trying to connect to a SQL SERVER 2008. Code works like a charm in windows and mac (with dotnet for mac). But I get an error on the ubuntu docker container.
Do you have any advice? thanks Connecting to SQL Server ... Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - Success) |
I have the same "hanging sql server connection" problem with this setup:
Before applying the SP3 , the error was about failures around TLS handshake. I've tried changing the base images, but all of the dotnet 3.1 images have the same problem. This same app can connect normally on Windows, and the container can connect normally on SQL Server 2014 (SP3). |
Could you try removing the SECLEVEL scripts and let driver connect with TLS 1.2 if your server has all the updates? |
@cheenamalhotra I've tried that too, didn't work. |
@albeserra have you managed to resolved this case? We also had this issue on service running on container.
May i what does this line means? What does it do? TIA |
Hi all, Updating the CA certificates in the base image of container have solve this for our case. See docker file below. I tried many options including @albeserra suggestions and I have remove many things and trimmed to this only command and it seems to what have resolved our case.
Background:
|
After some days I tried this again and managed to get the container working with the @iarovyi sugestion. Idk what I was doing wrong previously, probably not building the container image correctly.
@rdagumampan It comments out the |
Hi, no I didn't solve it. We abandoned the idea to build a .NET image for a linux container :( how did you solve it? |
@sjc1832 did you solve this issue ? could you provide details please |
@voroninp did you solve this issue ? could you provide details please |
@kolesso-programist Alas, I quit that company, so cannot add more details on whether issue was resolved or not. |
you made my day happier |
Hi everyone, since #577 fixes the hang issue and will be released with Microsoft.Data.SqlClient v2.0.0, we will close the issue. This fix will also be backported to System.Data.SqlClient soon. The recommended solution for anyone facing "End of Stream reached" exception in future is to verify target SQL Server supports TLS 1.2+ and server certificates are encrypted with SHA256+. There are workarounds to switch back to lower TLS version if needed, as discussed above, but starting next release (v2.0), applications will also receive a warning as implemented in #591 if a lower insecure TLS version was negotiated with server, since these versions are not recommended for client applications. It includes raising warning for TLS v1.0 and TLS 1.1 protocols. |
Thanks a lot man, you save alot of my 3 days of struggling |
I'm using Microsoft.Data.SqlClient 1.0.19128.1-preview on Linux RHEL 6 to connect to SQLServer running on Windows.
This is my connection string:
string connetionString Server="SomeComputer\SQLIntegTest,61245;Database=db4;uid=user;pwd=password;Trusted_Connection=No"
with this code:
SqlConnection cnn = new SqlConnection(connetionString);
cnn.Open()
I get the following error. The same code works on windows. Any help would be appreciated.
Unhandled Exception: Microsoft.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=118; handshake=271; [Login] initialization=11; authentication=14; [Post-Login] complete=14041; ---> System.ComponentModel.Win32Exception: Unknown error 258
--- End of inner exception stack trace ---
at Microsoft.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 Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry)at Microsoft.Data.SqlClient.SqlConnection.Open()
Abort (core dumped)
The text was updated successfully, but these errors were encountered: