SQL Server timeout exception azure hyrbrid connection

Amal Edirisinghe 0 Reputation points
2025-01-08T09:03:51.95+00:00

We have a Web application with Azure functions, a web app and an API manager. SQL database is located on an on-premise SQL database server. Functions apps connecting on-premise database via Azure hybrid connection. Suddenly we got the following error when the system was highly used. We are running the P1V3 premium app service plan.

Does anyone have experience with this error and do you have any recommendations here?

Error

Error] Error in GetCasesConnection 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=0; handshake=14987;

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,399 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,060 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shree Hima Bindu Maganti 2,745 Reputation points Microsoft Vendor
    2025-01-08T12:52:48.46+00:00

    Hi Amal Edirisinghe ,
    Welcome to the Microsoft Q&A Platform!
    The error you’re facing a timeout during the SQL Server pre-login handshake, which typically happens when the SQL Server is unable to respond within the expected time frame. This issue can arise due to high latency, network congestion, insufficient resources, or improper configuration.

    • Use tools like SSMS, Windows Performance Monitor, and SQL Profiler.
    • Optimize queries, add indexes, or increase server resources (CPU/RAM).
    • Update connection string. Connection Timeout=60;
    • Check diagnostic logs in Azure Portal for latency or dropped connections.
    • Configure a secondary hybrid connection for failover.
    • If possible, migrate the database to Azure SQL to reduce dependency on on-premise infrastructure.
    • Upgrade to a higher-tier plan like P2V3 or increase instance count.
    • Review firewall rules and use Azure Network Watcher to troubleshoot connectivity issues.
    • Add Max Pool Size=100; to the connection string.
    • Add retry mechanisms for transient errors.
        for (int retry = 0; retry < maxRetries; retry++) {  
            try { /* Attempt operation */ break; }  
            catch (SqlException ex) { Thread.Sleep(TimeSpan.FromSeconds(2)); }  
        }  
      
      ref:https://learn.microsoft.com/en-us/azure/app-service/app-service-hybrid-connections Let me know if further assistance is required.
      If the answer is helpful, please click Accept Answer and kindly upvote it
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.