Skip to content

Pre-Login timeout #4418

Description

@paxhj1990-stack

Connection timeout after upgrading to the latest version: 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=16155; handshake=33;

If add Connection Timeout=60 to the connection string, the connection can succeed; alternatively, using AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true); can also make the connection succeed.

Activity

  1. github-actions commented on Jul 1, 2026

    @github-actions

    🔍 Triage Summary

    Check Result
    Issue type Bug
    Environment ⚠️ Missing: SqlClient version, .NET target framework, SQL Server version, Operating system, repro code
    Area Area\Native SNI
    Duplicates Potentially related: #3118, #2005
    Regression Likely regression — reporter states "after upgrading to the latest version" but no prior version specified

    Analysis

    This issue reports a connection timeout during the TDS pre-login phase, where initialization takes ~16 seconds (well over the default 15-second connection timeout), causing the connection to fail. The two workarounds — increasing Connection Timeout to 60 seconds, or switching to managed networking via AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true) — strongly point to the native SNI code path on Windows as the root cause: since managed SNI resolves the issue, the delay is almost certainly introduced in the native SNI pre-login initialization routine (possibly DNS resolution, socket setup, or TLS negotiation). Severity: P2 — connections fail with default settings but usable workarounds exist.

    Next Steps

    @paxhj1990-stack, please provide the following details so we can investigate:

    1. Microsoft.Data.SqlClient version (e.g., 5.2.2, 6.0.0) — found on the NuGet package or Microsoft.Data.SqlClient.dll file properties
    2. Version you upgraded from (the last version where connections worked)
    3. .NET target framework (e.g., .NET Framework 4.8, .NET 8.0, .NET 9.0)
    4. SQL Server version (e.g., SQL Server 2019, Azure SQL Database)
    5. Operating system (e.g., Windows 11, Windows Server 2022)
    6. A minimal repro — a short code snippet or connection string (redact credentials) that reproduces the timeout

    Once environment details are provided, this should be assigned to the Copilot coding agent to investigate the native SNI pre-login initialization timing difference relative to managed SNI, with focus on socket setup and TLS negotiation in the native SNI path.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for issue #4418 · 35.3 AIC · ⌖ 7.05 AIC · ⊞ 8.4K · ◷

  2. moved this from To triage to Done in SqlClient Boardon Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions