Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When a player on an iOS client is connected to a stable (e.g., desktop) server and the player locks their device, then the server displays the error message
SocketException: Broken pipe (OS Error: Broken pipe, errno = 32), address = 0.0.0.0, port = 4567
and shuts down.This means players on iOS clients need to refrain from locking their device, or risk booting all other clients from the server.
Steps to reproduce
No specific notes apply for the server. I tested on a Debian VM against the tip of
main
(commit 7f987ea) in debug mode.Server environment specifics (for completeness)
For the client, I tested on iOS 18.12.1 against release v1.10.1.
❗️ Do not run the iOS client in debug mode (as that'll start a background task to keep the Flutter debug connection alive).
❗️ Do not have another app running that keeps Wi-Fi active (e.g., Twitch or YouTube with a live stream playing).
tcp port 4567
.)SocketException: Broken pipe
error is displayed, and the host server shuts down.Digging deeper
A few seconds after the the iOS device is locked, usually one of the following occurs.
FIN
(as if starting a graceful connection termination) thenRST
.onError
handler trips on anEPIPE
error, and shuts down.RST
.onError
handler swallows anECONNRESET
error, then theonDone
handler cleans up and displays theClient left.
message.Handling of
EPIPE
was introduced in commit 35a03b7. I'm not sure whyEPIPE
s are so fatal as to require stopping the server.This patch assumes that socket exceptions (like
EPIPE
) are only fatal if we're midway through assembling a message.If this is a faulty assumption, and there are cases where
EPIPE
should be treated as fatal, please let me know.(I have not explicitly tested this patch against other combinations of client and server devices.)
(Also, as an aside, I suspect
leftOverMessage
should be per-client, but that's a race we can prove/fix later.)