Question

Recently I found that connections were failing from one of our webservers to an MSSQL AlwaysOn Listener. The listener has two IP addresses because it spans subnets so we are specifying Multisubnetfailover=true in our connection string.

When attempting to make a connection to the listener I get the following error:

System.Data.SqlClient.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=20991; handshake=0;  ---> System.ComponentModel.Win32Exception     
(0x80004005): The wait operation timed out at     
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32     
waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions     
userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 
retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, 
TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, 
DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, 
DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, 
DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at IRNXMLGateway.Controllers.IRNXMLGatewayController.GenericCall(String methodCall) in 
CODELINE:line 376
ClientConnectionId:92074b33-176a-4006-b7c7-892e01a3eea7

I have also tried to connect using SSMS and ran into the same timeout issue.

I am able to successfully make connections by:

  • Connecting directly to the host without the listener
  • Connecting directly to the current listener IP address
  • Increasing the connection timeout to 200 seconds
  • Removing the MultiSubnetFailover option in the connection string

I am not experiencing this issue when attempting to connect from other servers. There are no errors in either the SQL or windows event logs to help determine the cause of the timeouts. Network trace shows the proper connection handshake with the current listener IP address. Neither servers have firewall or antivirus enabled. Webserver is running server 2008 web edition, SQL server is running windows server 2012 and sql server 2012.

Was it helpful?

Solution 2

So "I THINK" i was able to fix this. I re-installed .NET 4.5 and rebooted the server and now connections are made without issue. My current thought is that whoever installed 4.5 originally did not follow up with the required system reboot, leaving things in a weird state. I am going to continue to monitor this server for a few weeks to see if the problem re-occurs. I still appreciate any other opinions on what may have caused this.

OTHER TIPS

Is the following true: You have an active Transport Driver Interface (TDI) filter driver that is installed on the client application workstation.

If so there is a KB article at MS on this issue.
http://support.microsoft.com/kb/2870437

So we have had exactly the same recently and seemed to coincide with patch Tuesday from MS for September 2014. As a temporary fix I put in the "active" listener IP in the hosts file so it would always resolve locally and everything works. I suppose I could also have deleted the 2nd IP in the failover cluster.

Telnet seems to confirm that it takes 21 seconds before timeout when connecting to the listener, which matches with a serial DNS lookup of listener IP`s and getting "the wrong one". Still searching for a final answer, but definitely going to try the reinstall of 4.5 .NET as I read that the .NET library times out after 15 seconds, so DNS never gets the chance to send the 2nd IP to the client.

This is a client side issue. I just had it occur on a Sql 2012 from a Windows 7 client based application. The advice you got earlier about the KB article was right on. It was initially provided to me by a Microsoft engineer to correct our issue.

If yours is the same issue, you can create a test app that loops a connection. Set the connection timeout = 6000 and display a loop counter. You will see it hesitate initially and then zoom through the iterations.

Install the recommended KB hotfix.

Rerun the test app ands you should see no hesitation at all.

Check that tcpip is enabled on the sql box

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top