Skip to content

ssl_shutdown_timeout=0 default in 3.12.11+ causes intermittent "ssl:default cannot contact to DNS server" errors in high-concurrency environments #11323

@arthurhuangzh

Description

@arthurhuangzh

Describe the bug

Environment

  • aiohttp version: 3.12.11+ (specifically tested with 3.12.13)
  • Python version: 3.9
  • Platform: AWS Lambda (Python runtime)
  • Related dependencies: aiodns (latest), pycares (latest), aiosignal (latest)

Problem Description

Intermittent connection failures occurring after Lambda functions run for extended periods under high load, presenting with the misleading error message:

ClientConnectorError: Cannot connect to host api.xxxxx.com:443 ssl:default cannot contact to DNS server

Root Cause Analysis

The change in aiohttp 3.12.11+ where ssl_shutdown_timeout default value changed from 0.1 to 0 causes aggressive connection closure without proper SSL shutdown handshake.
Technical Mechanism

  1. Connection Creation: Lambda instance establishes HTTPS connections normally
  2. Aggressive Closure: ssl_shutdown_timeout=0 causes immediate TCP RST instead of graceful SSL shutdown
  3. State Inconsistency: DNS cache retains valid entries while connection pool references become stale
  4. Subsequent Failures: New Lambda instances attempt to use cached DNS data with inconsistent connection states
  5. SSL Handshake Failure: Server-side detects previous connection anomalies during new SSL handshake
  6. Error Misreporting: SSL handshake failures get incorrectly reported as DNS contact failures

This Represents a Significant Breaking Change

We believe the ssl_shutdown_timeout default value change from 0.1 to 0 in version 3.12.11+ constitutes a significant breaking change that warrants more prominent documentation and community awareness.

To Reproduce

TBD

Expected behavior

The application should continue to function as expected after upgrading aiohttp, aiodns, aiosignal, and pycares to their latest versions.

Logs/tracebacks

ClientConnectorError: Cannot connect to host api.xxxxx.com:443 ssl:default cannot contact to DNS server

Python Version

$ python 3.9

aiohttp Version

aiohttp version: 3.12.11+ (specifically tested with 3.12.13)

multidict Version

$ python -m pip show multidict

propcache Version

$ python -m pip show propcache

yarl Version

$ python -m pip show yarl

OS

AWS Lambda (Python runtime)

Related component

Client

Additional context

While we understand that the ssl_shutdown_timeout change may have been intended as an optimization, its impact in production environments qualifies it as a breaking change that deserves prominent documentation. This would help the community avoid the costly debugging and production issues we experienced.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-infoIssue is lacking sufficient information and will be closed if not provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions