Improved MultiSubnet Listener Behavior With Newly Released SQL Client Provider in .NET 4.6.1
Published Jan 15 2019 04:48 PM 1,987 Views
First published on MSDN on Dec 01, 2015

SQL Client Provider Behavior With MultiSubnet Listener Results in Connection Timeouts

The first experience trying to connect to an availability group listener defined with multiple IP addresses, may be intermittent connection timeouts.

The default behavior of the SQL client libraries is to try all IP addresses returned by the DNS lookup - one after another (serially) until the all of the IP addresses have been exhausted and either a connection is made, or a connection timeout threshold has been reached. This can be problematic, because depending upon DNS configurations, the “correct” or “online” IP address may not be the first IP address returned. The default timeout for a TCP connection attempt is 21 seconds and if the first IP address attempted is not online, it will wait 21 seconds before attempting the next IP address. For each subsequent IP address, it will again have to wait 21 seconds before moving to the next IP address until the connection attempt times out or it establishes a connection to an IP address that responds.

For more information on the symptoms associated with the SQL Client’s legacy default behavior (MultiSubnetFailover=FALSE) see our other AlwaysOnPro article:
Connection Timeouts in Multi-subnet Availability Group

Improved SQL Client Provider Defaults to MultiSubnetFailover=TRUE

That changes with the updated SQL Client provider shipping in .NET 4.6.1. Now SQL Client Provider's default behavior is to retrieve all IP addresses up front and attempt to connect to them all in parallel. This should result in the successful connection to the online IP addresss and is the optimal way to reconnect to an availability group in the event of failover.

The following article describes the improvement in more detail and a download link to the updated .NET package:
.NET Framework 4.6.1 is now available!

Improve MultisubnetFailover connection behavior for AlwaysOn

The SqlClient now automatically provides faster connection to AlwaysOn Availability Group that was introduced in SQL Server 2012. It transparently detects whether your application is connecting to an AlwaysOn availability group (AG) on different subnet and quickly discovers the current active server and provides connection to the server.

Prior to this release, an application has to set connection string to include “MultisubnetFailover=true” to indicate that it is connecting to AlwaysOn Availability Group. Without turning on the connection keyword, an application might experience a timeout while connecting to AlwaysOn Availability Group.

With this feature an application does not need to set MultisubnetFailover to true anymore. For more information about SqlClient support for AlwaysOn Availability Groups, see SqlClient Support for High Availability, Disaster Recovery .

For more information on SQL Client Provider support for High Availability and specific support for the MultiSubnetFailover connection string parameter see:
SqlClient Support for High Availability, Disaster Recovery
Version history
Last update:
‎Jan 15 2019 04:48 PM
Updated by: