RemoveForwardedPort when disconnected
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Hi folks.
My scenario is long running SSH tunneling connection with a number of ForwardedPortRemote's.
I do
sshClient.ErrorOccurred += delegate (object sender, ExceptionEventArgs e){ . . . }
and
portRemote.Exception += delegate (Object source, ExceptionEventArgs args){ . . . }
and then handle these events.
Since it is long running connection, when it gets disrupted (cable plugged off, internet down etc), the software then tries to reconnect ssh client. As soon as the Internet access is again available, it reconnects.
When the connection gets interrupted and the above events fire, I want to stop/dispose/remove forwarded ports from the ssh client, so when the new connection is established, there are no leftover unused/stopped ports.
The problem is when I call SshClient.RemoveForwardedPort(port), it throws "Client not connected" exception. And it throws it both when its disconnected and after reconnection too. Thus I cannot remove "old" forwarded unused ports.
How or at what point can I remove those ports? Or eventually can I reuse them?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SshClient.RemoveForwardedPort, ForwardedPortRemote, and the ErrorOccurred and Exception event flow described in the issue. Trace how forwarded ports behave across disconnection and reconnection, then verify that stopped ports can be removed or reused without a "Client not connected" exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100