Skip to content

Bug: SSH tunnel not restarted on unexpected exit #132

@shanselman

Description

@shanselman

Summary

When the SSH tunnel process exits unexpectedly, SshTunnelService only logs a warning. It does not clean up _process/_lastSpec, does not raise any event, and does not attempt a restart. The gateway client keeps reconnecting to ws://127.0.0.1:<localPort> which is now unreachable.

Location

src/OpenClaw.Tray.WinUI/Services/SshTunnelService.cs lines ~123-134 (process.Exited handler)

Impact

If the SSH tunnel crashes, the entire remote connectivity feature is broken until the user manually intervenes (e.g., changes settings or restarts the app). The reconnect loop will spin forever against a dead localhost port.

Flagged by

Multi-model code review consensus (2/3 models: Opus, GPT-5.4)

Suggested Fix

  1. Null out _process and _lastSpec in the Exited handler so the next EnsureStarted call creates a fresh tunnel
  2. Expose a TunnelExited event that App subscribes to for triggering automatic tunnel restart and gateway reconnect
  3. Consider a bounded retry with backoff for automatic tunnel restart

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions