Repository navigation
Conversation
When the phone dropped over Wi-Fi, the TCP streamer turned end-of-stream (and streaming IO errors) into a fatal ConnectError. The runner replaced the streamer with a DummyStreamer, dropping the TcpListener, and the UI fell back to Default; the port stayed closed until a manual Disconnect -> Connect cycle. Treat end-of-stream and streaming IO errors as recoverable: the TCP streamer tears down the framed connection and rebinds the same port with a bounded exponential backoff (500ms, doubling, capped at 5s), then returns to Listening and emits StreamerMsg::Listening so the UI and tray follow. Bind through TcpSocket with SO_REUSEADDR so an immediate rebind does not fail on a TIME_WAIT socket. A manual Stop drops the streamer, which cancels the in-flight rebind, so the listener is not resurrected. Handshake failures, adb/usb device errors, and deserializer errors still propagate as fatal. TCP keepalive and ADB reverse-proxy re-establishment are left as follow-ups.
This was referenced Nov 24, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When the TCP connection ends (phone app closed, Wi-Fi switched, streaming IO error),
TcpStreamer::next()turns the end of the stream into a fatalConnectError::Disconnected/WriteError::Io. The streamer runner then drops theTcpStreamer— and with it theTcpListener— and the UI falls back toDisconnected. The phone cannot reconnect until the user performs a manual Disconnect → Connect cycle.Rebinding the same port immediately can also fail while the previous socket is in
TIME_WAIT. That is the same port-in-use symptom reported in #151 for ADB mode.Changes
TcpSocketwithSO_REUSEADDR(bind_reusable()), so a rebind right after a drop does not collide with the previous socket inTIME_WAIT.framed.next()returnsNone) and streaming IO errors other thanTimedOut/WouldBlockdrop the framed connection, rebind the same port, clear the per-connectionprocess_cache, and emitStreamerMsg::Listening.Stopdrops the streamer and cancels the in-flight rebind, so the listener is not resurrected.Behavior
After a phone app crash or a dropped connection the PC returns to Listening on its own and accepts the next connection; no manual Connect is needed. Between sessions the UI shows
Listeninginstead ofDisconnected.Verification
cargo fmt --all -- --checkListeningon the same port in ~0.73 ms with no PC-side click, and the phone reconnected immediately.Disconnecton the PC: no rebind observed for 65 s; port 54345 stayed closed, so a user-initiated stop is not resurrected.cargo build/cargo testwere not run locally (protocis not installed on this machine); CI covers the builds.Related to #151 and #136. The ADB reverse-proxy rebuild after a drop is a separate follow-up PR.