sshnet / sshnet/SSH.NET

System.Net.Sockets.SocketException in ForwardedPortLocal.StartPort

Open
#939 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

I have a piece of code that more or less does this:

var forwardedPort = new ForwardedPortLocal("127.0.0.1", (uint)boundPort, "127.0.0.1", (uint)port);

SshClient?.AddForwardedPort(forwardedPort);

forwardedPort.Start();

I often get this exception:

System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Renci.SshNet.ForwardedPortLocal.InternalStart()
at Renci.SshNet.ForwardedPortLocal.StartPort()

I wonder if there's anything that I could be doing wrong (doesn't seem at first sight) or if there's anything else going on.
Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ForwardedPortLocal.StartPort() and InternalStart() stack frames, then reproduce the bind using the shown ForwardedPortLocal setup. Determine whether the failure comes from the requested local endpoint or library behavior; done means documenting the cause and providing a verified fix or regression test.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.