question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EF Core SqlServer connect hang

See original GitHub issue

Describe the bug

Can not able to connect SQL Server instance. No exceptions, it just hangs at ‘OpenConnection’ function indefinitely. Even though I give 10 seconds of timeout, it does not timeout.

No exceptions. Just logs. Trace enabled.

May 13 09:08:46 ubuntu pompa-proxy[4071]: dbug: Microsoft.EntityFrameworkCore.Infrastructure[10401]
May 13 09:08:46 ubuntu pompa-proxy[4071]:       An 'IServiceProvider' was created for internal use by Entity Framework.
May 13 09:08:52 ubuntu pompa-proxy[4071]: info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
May 13 09:08:52 ubuntu pompa-proxy[4071]:       Entity Framework Core 3.1.4 initialized 'OrkaContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: CommandTimeout=10
May 13 09:08:52 ubuntu pompa-proxy[4071]: dbug: Microsoft.EntityFrameworkCore.Database.Connection[20000]
May 13 09:08:52 ubuntu pompa-proxy[4071]:       Opening connection to database 'ORKA_0996_2020' on server '192.168.0.250\ORKASQL'.

To reproduce

                var context = _serviceLocator.GetInstance<OrkaContext>();
                
                context.Database.OpenConnection();

                _logger.LogInformation("Execution is starting...");

                context.Database.ExecuteSqlRaw(@"...

Expected behavior

A connection should be opened or an exception should be thrown.

Further technical details

Microsoft.Data.SqlClient version: 3.1.4 .NET target: .NET Core 3.1.4 SQL Server version: SQL Server 2012 SP4 Operating system: Ubuntu 20.04 (Client) , Windows Server 2012 (Server)

Additional context It was working until I have upgraded my ubuntu. At first, I got an SSL exception. I have upgraded the SQL server to SP4 to resolve issue, it did solve problem. but hang problem started.

I can connect to the database from the server’s itself by sql server management studio using sql server authentication. There are windows computers in the office, I can confirm they can connect to the sql server, too.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
oguzhantopcucommented, May 13, 2020

I have resolved my issue by setting MinProtocol = TLSv1.1 at openssl.cnf. BTW MinProtocol = TLSv1.0 did not work, that was the main reason I have struggled with this issue for hours.

But I think infinite hang should be solved. It is up to you.

0reactions
cheenamalhotracommented, May 14, 2020

Could you also check if server certificate is not encrypted with SHA1? Related issue was also reported here: https://github.com/dotnet/SqlClient/issues/538#issuecomment-622587024

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with connecting on local SQL Server with EF Core 7
I have simple web application, it is generated from Visual Studio on version .NET 5 and EF Core 5, and only thing added...
Read more >
Breaking changes in EF Core 7.0 (EF7)
Complete list of breaking changes introduced in Entity Framework Core 7.0 (EF7)
Read more >
NET 6.0 - Connect to SQL Server with Entity Framework Core
This post shows goes through the steps to connect a .NET 6 API to SQL Server using Entity Framework Core, and automatically create/update ......
Read more >
Using SQL Server - Configuration
SQL Server is the default storage for Hangfire – it is well known to many . ... Choose either a connection string to...
Read more >
Tips for making the most of EF Core with Azure SQL ...
Enable retry of commands. EF Core includes a "connection resiliency" feature, that automatically retries failed database commands. (Not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found