Skip to content

ClientWebSocket.SendAsync doesn't error when the system-level internet connection is severed on linux #129096

@akiraveliara

Description

@akiraveliara

Description

WebSocket.SendAsync(ArraySegment<byte>, WebSocketMessageType, bool, CancellationToken) doesn't error or at least respect the cancellation token when the system is not connected to the internet and therefore cannot send on linux (cachyos, kernel 7.0.11-1-cachyos, glibc 2.43); instead, the messages end up silently in the abyss. On windows (windows 11 25h2) it works fine, and yields an error shortly after making the call.

Trying to (re?*)connect while the connection is severed causes the websocket to infinitely stay in WebSocketState.Connecting, thus rejecting any further reconnection attempts when the internet connection is restored.

* I haven't attempted this without first connecting with a working internet connection, this might be reconnecting-exclusive

Reproduction Steps

  1. Connect to a remote websocket, observe that it works
  2. Sever your local internet connection
  3. Payloads are now being sent into the void

Expected behavior

I should like to receive an error or some indication that it couldn't be sent, so that I can handle connection loss appropriately, like it works on windows

Actual behavior

Payloads are sent into the void.

Regression?

unknown, this happens on .NET 10 and .NET 11 pre 4

Known Workarounds

none

Configuration

tried running on .NET 10 and .NET 11 preview 4, reproduced it working on windows 11

dotnet --info ➜ dotnet --info .NET SDK: Version: 11.0.100-preview.4.26230.115 Commit: 4370ea1634 Workload version: 11.0.100-manifests.bd820daa MSBuild version: 18.7.0-preview-26230-115+4370ea163

Runtime Environment:
OS Name: cachyos
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/11.0.100-preview.4.26230.115/

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 11.0.0-preview.4.26230.115
Architecture: x64
Commit: 4370ea1634

.NET SDKs installed:
9.0.314 [/usr/share/dotnet/sdk]
10.0.300 [/usr/share/dotnet/sdk]
11.0.100-preview.4.26230.115 [/usr/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 11.0.0-preview.4.26230.115 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 11.0.0-preview.4.26230.115 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_BUNDLE_EXTRACT_BASE_DIR [/home/akiraveliara/.cache/dotnet_bundle_extract]
DOTNET_ROOT [/usr/share/dotnet]
DOTNET_TOOLS_PATH [/home/akiraveliara/.dotnet/tools]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.NetuntriagedNew issue has not been triaged by the area owner

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions