Skip to content

PlatformNotSupportedException with TcpClient.ConnectAsync #24917

Description

@cocowalla

I'm getting PlatformNotSupportedException on Linux when calling TcpClient.ConnectAsync(host, port), with a rather unhelpful message: Sockets on this platform are invalid for use after a failed connection attempt (I'm not trying to reuse a socket)

This is only happening under specific circumstances:

  1. host is a hostname, such as "localhost", AND
  2. KeepAlive is enabled using tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true)

Everything works fine if I change either one of these things.

I did a search and came across issues #16263 and #17374, which led to PR dotnet/corefx#16373 - so it seems like you are supposed to be able to connect using a hostname, it's just not working when keep alives are enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.NetenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions