Share via


Timeout error while attempting to consume the pre-login handshake

Question

Tuesday, June 19, 2018 1:45 PM

Hi,

I have problem with 

Timeout error while attempting to consume the pre-login handshake

This is my original exception

SqlException (0x80131904): 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=3371; handshake=14150;

Have contacted knowledge-center/technical-chat and have instructions to check those 7 things

1. An instance of the SQL Server Database Engine is not running. DONE RUNNING
2. The SQL Server Browser service is not running. DONE RUNNING
3. The TCP/IP is disabled. DONE ENABLED
4. The server name was typed incorrectly. USING MY IP ADDRESS Data Source=**.*.**.***
5. There are network problems. ******* Connected xx.x.xx.xxx : 1433 ********
6. The TCP/IP port for the Database Engine instance is blocked by a firewall. FIREWALL DISABLED
7. The client and server are not configured to use the same network protocol. IPV4 and IPV6 are enabled

Thanks for help.

BR

All replies (5)

Wednesday, June 20, 2018 8:07 AM âś…Answered

Hi Srka,

I suggest you firstly ensure the database server is ready for remote access. You can install a SSMS in another machine inside your intranet and see if it can connect to your database.

Then try increasing the timeout in connection string.

Make sure your Configuration with Hybrid connection is correct.

Connect to on-premises SQL Server from a web app in Azure App Service using Hybrid Connections

Regards,

Pirlo Zhang 

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


Tuesday, June 19, 2018 2:36 PM

Hello,

Is your question related to a SQL Server on-premises instance or a SQL Server instance on a VM (IaaS)?

.

Regards,

Alberto Morillo
SQLCoffee.com


Tuesday, June 19, 2018 9:06 PM

Hi,

I am trying to reach SQL Server which is installed on local server(in home), from Azure hosted web page.

I have Hybrid Connection between those two instances:

kucnirac Connected **.*.**.*** : 1433 testHybrid1

This is my connection string:Data Source=**.*.**.***;Initial Catalog=TEST;Trusted_Connection=True;User Id=User;

So I presume that you are thinking on SQL Server on-premises instance.. :)

Thanks.


Wednesday, June 20, 2018 11:00 AM

Hi Pirlo,

I have done all taht you suggested:

Install SSMS on new computer and connect to required SQL Server instance and everything goes smooth.

I have removed old Hybrid connection and created new one and now getting almost the same error:

SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

BR,

Srdjan Drobnjak


Wednesday, June 20, 2018 12:10 PM

Hi,

I have resolved this issue.

It was connection string which was problematic. I have been using Windows Authentication and when changed this to SQL Server Authentication all suddenly worked (after 2 days :) )

Anyway maybe someone would need this:

string myconnectionString = "Server=SERVER_NAME,1433;Database=DATABASE_NAME;User Id=**;Password=**";

In web.config file:

<connectionStrings>
    <add name="myconnectionString" connectionString="Server=SERVER_NAME,1433;Database=ODDS_ENGINE;User Id=**;Password=**" providerName="System.Data.SqlClient"/>
  </connectionStrings>

Anyway, thanks for support, this is the link that I have followed (Pirlo Zhang) which gives me the right direction:

https://github.com/wbuchwalter/azure-content/blob/master/articles/app-service-web/web-sites-hybrid-connection-connect-on-premises-sql-server.md#connect-to-on-premises-sql-server-from-a-web-app-in-azure-app-service-using-hybrid-connections

BR.