Skip to content

SocketAsyncEventArgs.ConnectSocket can't be explicitly cleared #30252

@stephentoub

Description

@stephentoub

This means SocketAsyncEventArgs that are pooled (as they're meant to be) and are used to establish connections can end up keeping a Socket instance alive indefinitely (until the SocketAsyncEventArgs is used for another connect operation).

This affects SocketsHttpHandler, for example. It pools SAEAs used to establish connections. If an SAEA ends up back in the pool, and new connections aren't established frequently enough to cause it to be reused, and a developers drops an HTTP/1.1 response stream before reaching the end of the response body and without disposing of it, the connection may remain open (until the server closes it or the pool reuses the SAEA for another connection).

I'm not sure how to address this without new API, e.g. a setter on ConnectSocket that can be set to null, a Clear method on SAEA that clears all such state, etc.

cc: @davidsh, @geoffkizer

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Net.Socketstenet-reliabilityReliability/stability related issue (stress, load problems, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions