Skip to content

SqlConnection.Open hangs indefinitely with MultiSubnetFailover=True #19

@priyankatiwari08

Description

@priyankatiwari08

Describe the bug

When connecting to a SQL Server availability group listener with MultiSubnetFailover=True in the connection string, SqlConnection.Open() hangs indefinitely instead of timing out after the specified ConnectTimeout.

To reproduce

var cs = "Server=mylistener.domain.com;Database=MyDB;MultiSubnetFailover=True;ConnectTimeout=15;Integrated Security=True";
using var conn = new SqlConnection(cs);
conn.Open(); // hangs forever, never times out

The listener has two subnets configured. When one subnet is unreachable, the connection attempt never fails over and never respects the timeout.

Expected behavior

Connection should either succeed by failing over to the reachable subnet, or throw a SqlException after the 15-second ConnectTimeout.

Actual behavior

The call to Open() blocks indefinitely. No exception is thrown. Thread dump shows it stuck in SNI connection attempt.

Further technical details

Microsoft.Data.SqlClient version: 5.2.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions