Skip to content

fix: dispatch the first queued message without BeginInvoke - #9

Merged
RobertPoienar merged 2 commits into
AltServer-Websocket-Sharpfrom
fix/181-dispatch-first-message-without-begininvoke
Aug 10, 2026
Merged

fix: dispatch the first queued message without BeginInvoke#9
RobertPoienar merged 2 commits into
AltServer-Websocket-Sharpfrom
fix/181-dispatch-first-message-without-begininvoke

Conversation

@andreion1ca

Copy link
Copy Markdown

An app or Desktop that sent its first frame before the server returned from OnOpen was dropped as it connected (AltTester-Server issue sta#181):

[Error] Operation is not supported on this platform.
[Fatal] Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'.
... disconnected.1006-An exception has occurred while receiving.

open() ended by handing the queued message to Delegate.BeginInvoke, which is unsupported on .NET Core and throws PlatformNotSupportedException. The exception escaped open() -> Accept() -> StartSession() into the accept loop, which logged it and closed the TcpClient; that disposed the stream the receive loop was already reading, so the loop died and aborted the session with 1006.

Queue the message on the thread pool instead. Only reached when a frame arrives while OnOpen is still running, which is why SDK 2.3.2+ and Desktop hit it (both speak immediately on connect) while older SDKs, silent until the server speaks first, never did.

An app or Desktop that sent its first frame before the server returned from
OnOpen was dropped as it connected (AltTester-Server issue sta#181):

  [Error] Operation is not supported on this platform.
  [Fatal] Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream'.
  ... disconnected.1006-An exception has occurred while receiving.

open() ended by handing the queued message to Delegate.BeginInvoke, which
is unsupported on .NET Core and throws PlatformNotSupportedException. The
exception escaped open() -> Accept() -> StartSession() into the accept
loop, which logged it and closed the TcpClient; that disposed the stream
the receive loop was already reading, so the loop died and aborted the
session with 1006.

Queue the message on the thread pool instead. Only reached when a frame
arrives while OnOpen is still running, which is why SDK 2.3.2+ and Desktop
hit it (both speak immediately on connect) while older SDKs, silent until
the server speaks first, never did.
@RobertPoienar
RobertPoienar merged commit 3e1d78a into AltServer-Websocket-Sharp Aug 10, 2026
1 check passed
@andreion1ca
andreion1ca deleted the fix/181-dispatch-first-message-without-begininvoke branch August 10, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants