0

I have created and am running SQL Server on Docker (on Mac). I am able to connect to it on Azure. I was able to run dotnet ef database update and the database appears in azure.

However, when I run my asp.net project and try to run a simple GET request to the database I get a pre-login handshake error. The GET request shouldn't be the problem as I am following a tutorial and it's basically the same.

I have specified the connection chain in appsettings.json:

"ConnectionStrings": {
    "CodeCamp": "Data Source=localhost, 1433;Initial Catalog=PSCodeCamp;User ID=sa;Password=Password-Is-L0ng"
  }

I used the same credentials to connect in Azure.

TL:DR: Handshake error in Rider/Postman, Working fine in Azure.

I also noticed that if I try to connect in azure while the app is running I get the same handshake error in Azure and I also tried to disconnect azure before running the app, still getting the same error.

The error in question:

The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.  This could be because the pre-login handshake failed or the server was unable to respond back in time.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=40; handshake=14974; 
4
  • A pre-login handshake error, especially when using SQL Login details, suggests a TLS problem. If you add ;Encrypt=false to your connection string, which turns off all connection encryption, does it connect successfully? If so, consider using ;TrustServerCertificate=true instead, which accepts the self-signed X.509 certificate installed with SQL Server - the connection will be encrypted but the client doesn't attempt to verify the identity of the server. Commented Jan 14, 2022 at 14:49
  • No luck, I get the same error, no changes. Commented Jan 14, 2022 at 14:57
  • Is the ASP.NET app running on the macOS host itself, or is it also running in a Docker container? If the latter try Data Source=host.docker.internal,1433 instead. Note this would only work when running inside Docker Desktop. Commented Jan 14, 2022 at 15:08
  • It's running on macOS, not on Docker. Thank you anyway! Commented Jan 15, 2022 at 15:21

2 Answers 2

1

Depending on the image, the Password part of your connection string should be replaced with SA_PASSWORD. There's some information on the dockerhub but not too informative.

Sign up to request clarification or add additional context in comments.

Comments

0

Try below steps to solve this issue as there are multiple cases for the mentioned error message:

  1. Try to connect with IP Address instead of DNS.
  2. Check SQL Engine connectivity.
  3. Check the status of SQL Server service.
  4. Configure client and server under same protocal.
  5. Check firewall settings for ports.

Check this blog to understand more about troubleshooting the error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.