Skip to content

phone-ssh: allow slower USB handshakes - #504

Merged
derekross merged 3 commits into
derekross:mainfrom
quatrixone:phone-ssh-timeout
Nov 8, 2026
Merged

derekross merged 3 commits into
derekross:mainfrom
quatrixone:phone-ssh-timeout

Conversation

@quatrixone

@quatrixone quatrixone commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Keep the default phone-ssh connection timeout at 6 seconds, configurable through OMAMOBILE_SSH_CONNECT_TIMEOUT as a positive integer number of seconds. The same value is passed to the USB-bound proxy socket. Invalid values are rejected before SSH starts.

This keeps ordinary connection failures quick while allowing a slower USB handshake to opt in to a longer timeout.

Checks

  • tests/phone-ssh passed, covering default, override, invalid values and proxy propagation.
  • git diff --check passed.
  • No phone timing test was run.

Use a 20-second connect timeout so every device gets enough time during USB link setup and optional NFS-root startup. A dead connection can now take up to 14 seconds longer to report failure.
@derekross

Copy link
Copy Markdown
Owner

Thanks. A slow first handshake is worth handling, and I appreciate that you
spelled out the cost in the description.

I'd rather not move the default for every phone, though. When a phone is
rebooting, the USB link is gone and the address usually routes out through the
laptop's normal gateway, so each connect waits the full timeout instead of
failing at once. Our wait loops count attempts, so they stretch with it. The
"waiting for SSH" loop after a bin/omamobile flash, for example, would go from
about six minutes to about sixteen before it gives up. tools/usbc-deadman
would also get fewer confirmation attempts inside its window. Also, since #467
the relay used with OMAMOBILE_SSH_INTERFACE does the TCP connect itself, with
its own 6-second timeout (tools/phone-ssh-proxy, line 100), so on that path
the change wouldn't give the Mi 8 more time.

Could you make it an option instead?

  • OMAMOBILE_SSH_CONNECT_TIMEOUT, a whole number of seconds with 6 as the
    default, refused if it isn't a number, and listed in the header with the other
    variables;
  • passed on to phone-ssh-proxy for its connect timeout;
  • a tests/phone-ssh case for the default, an override and a bad value.

The Mi 8's notes can then set it, and the other phones keep what they have. If
you have a timing from the Mi 8 (how long the first connect takes after the
gadget appears), please add it to the description. It'll tell us whether 20 is
the right number. The NFS-root part can wait for #503.

@derekross

Copy link
Copy Markdown
Owner

Thank you, this is exactly what I asked for. The default stays at 6 seconds. OMAMOBILE_SSH_CONNECT_TIMEOUT is checked as a positive whole number before anything starts, it's documented in the header, and it reaches phone-ssh-proxy's own connect timeout too. The test covers the default, an override, five bad values and the proxy command line. I ran tests/phone-ssh on the branch and it passes.

One wording nit, and I can fix it when I merge: the new comment above opts mentions the NFS-root startup, which is still in review in #503. "A slow USB link setup can delay the first handshake" is enough for now.

CI was cancelled on the runner's side, not because of anything in the branch. I'll re-run it and merge once it's green, as phone-ssh: OMAMOBILE_SSH_CONNECT_TIMEOUT for phones with a slow first handshake. If you get a timing from the Mi 8 (how long the first connect takes after the gadget appears), #505's runbook is a good place to record the value to use.

@derekross
derekross merged commit 1e85e30 into derekross:main Nov 8, 2026
2 checks passed
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
… handshake (derekross#504)

Some phones take longer than ssh's default to finish the first SSH
handshake while their USB link is still coming up. tools/phone-ssh and
tools/phone-ssh-proxy now take the connect timeout from
OMAMOBILE_SSH_CONNECT_TIMEOUT, defaulting to 6 s as before, so a slow
phone can ask for more without making a dead connection slower to
report everywhere else. tests/phone-ssh covers the default and the
override, and that the proxy receives it.
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