ASP.NET Core 3.1 API on AWS - Connection Timeout Expired intermittently - sql-server

I have ASP.NET Core 3.1 API hosted in AWS (on IIS 10 and SQl Server on separate Box). More frequently than I would like, I am getting the below error (intermittently).
Error : Connection Timeout Expired. 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=21020; handshake=0;
Here is the conenction string:
"ConDB": "Server=SqlServerName;Database=Test;user id=User;password=xyz;MultipleActiveResultSets=true;Application Name=AppName;TrustServerCertificate=true;"
If I add connect timeout=240;, I don't get the error but intermittently the connection to database takes a long time to establish before I see the API call results.
I have other .NET framework based projects on the same AWS setup, they all run fine.
Any help appreciated.

Related

The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement

I looked into bunch of similar questions but haven't find a solution for my problem. I have this error:
Connection Timeout Expired. 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=501; handshake=29876; (.Net SqlClient Data Provider)
I try to connect remote SQL Server instance from my dev machine via SSMS, specify ip address, not domain name. Tried all combinations of connection options.
Things I already checked:
not a problem with DNS because I use IP address
me and server supports similar network protocol
server is running, SQL Browser is running, server name and credentials are correct
my dev machine supports all versions of security protocols (e.g. TLS 1.2) and ciphers
I checked option "trust server certificate"
tried set a big timeout like 5 mins and got a little different error:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) (.Net SqlClient Data Provider)
In my opinion such kinds of errors mean that something wrong with security stuff. All network problems and firewall restrictions should not be a reason.
I'm sure that the server configured correctly because other developers don't have such problem with the same server. And version of my SSMS is not older than others.

SQL server unable to login from specific servers

I am trying to setup a new MS SQL server, but i am having trouble connecting it to the main app servers.
Points to note and things i have tried:
People can connect to the server remotely from their machines without any issue.
Tried setting up and enabling all the ip configurations under the instance.
Able to connect to remote shared paths between these servers.
Able to see logs saying server is listening on 127.0.0.1 and ::1
Error seen:
Via IIS-
Connection Timeout Expired. 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=14800;
handshake=13501; ]
vis SQLCMD -
Unable to complete Login process due to delay in opening server
connection.
Is there somewhere else i should be looking.? I am not sure if the issue is with the App server or DB server even.

Failed to connect from SQL Server database to MS Power BI Desktop

I want to connect my Power BI Desktop from my server. But it fails to connect and throws an error by entering the following information of my server
Microsoft SQL: Connection Timeout Expired. 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=457; handshake=29589;
I also checked the below advanced option. But the error remains same.
By using correct server name and password without port name. I have connected my MS SQL with Power BI.
The main issue was that i was using username and password of server.

Connection Timeout Expired ... [Pre-Login] initialization=211; handsake=14787;

I have to add "service based database" in my visual studio 2017 community, but i found this message:
"Connection Timeout Expired. 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=211; handshake=14787;"
can anyone tell me what i must to do?
The “Connection Timeout expired” error commonly occurs in the following cases:
An instance of the SQL Server Database Engine is not running.
The SQL Server Browser service is not running.
The TCP/IP is disabled.
The server name was typed incorrectly.
There are network problems.
The TCP/IP port for the Database Engine instance is blocked by a firewall.
The client and server are not configured to use the same network protocol.
this link might help you, Connection Timeout expired
I´ve had same issue. It was Network issue. Firewall was dropping the packets in application level. We have able to access Ip and port by telnet ok, but does not by any SQL Client. Please contact your network administrator

ssms connection timeout expired pre-login handshake error

I am unable to connect to SQL Server using SSMS 2014/2012. But able to connect successfully using DBVisualizer.
Getting below error:
Connecton Timeout Expired. The tmeout 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 tme. The duraton spent While attempting to connect to
this server vvas - [Pre-Login] initializaton=18096; handshake=14271;
(Microsoft SQL Server)
I have tried the below solutions, but still no luck:
telnet serverip 1433 - works fine from my computer
Connection to SQL Server Works Sometimes - To try this, I installed SQLServerAdvancedServices and then, for each listed IP address, set Active and Enabled to Yes. When I install just SSMS, these options don't even show up.
What else can I try here to get it working? Thanks in advance.

Resources