Repository navigation
fix(android): let a newer host replace a session that went quiet - #32
Merged
heoblitz merged 1 commit intoOct 30, 2026
Merged
Conversation
After the cable is pulled, the phone can keep the old connection open, and the runtime handled one session to the end before accepting another, so the Mac's probes after a replug waited in the backlog until the app restarted. Each accepted connection is now handled on its own, and it replaces the current session only once its handshake is accepted. A connection that never answers, or is refused, leaves a working session and its status alone.
heoblitz
approved these changes
Oct 30, 2026
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.
Summary
Fixes the reconnect after a cable replug reported in #31: the Android app stayed out of Necto until it was restarted.
Cause.
NectoSdkRuntime.servehandled one session to the end before it calledaccept()again. After an unplug the phone kept the old connection established, so the runtime stayed blocked reading it, and the Mac's probes after the replug piled up in the backlog.handle()already closed a previous session when a new one arrived, but a second one never got that far.Fix.
stop()also closes connections that are still handshaking, since their reads block and are not woken by cancellation.Tests
aNewerHostReplacesOneThatWentQuiet: a connected host goes silent, a second host handshakes, the first is closed and the second answerstest.echo. On the old runtime this test hangs.aHostStillSayingHelloLeavesTheConnectedOneAlone: a second connection that has only read the hello, then is refused, leaves the first answering and the statusConnected.SDK/Android/gradlew -p SDK/Android testpasses.Device check
Galaxy S25+ over USB,
script/android-sample R3CY70P3F4H, then unplug and replug without touching the app:After the replug,
plugin send plugin-sample host.infoanswered, the app kept the same process, and/proc/net/unixshowed only the listener and one connection.Not in this PR
NectoSDKRuntime.swift. I have not unplugged an iPhone, so I don't know whether usbmuxd closes the socket on the phone and hides this there.