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;
;Encrypt=falseto your connection string, which turns off all connection encryption, does it connect successfully? If so, consider using;TrustServerCertificate=trueinstead, 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.Data Source=host.docker.internal,1433instead. Note this would only work when running inside Docker Desktop.