sshnet / sshnet/SSH.NET

CreateShellStream throwing "Failed to open a channel after 10 attempts" because LocalPacketSize is too big for server side

Open
#1,523 0 comments 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 ran into a problem where an old Extreme Networks switch was always giving “Connect failed: hostname, Renci.SshNet.Common.SshException: Failed to open a channel after 10 attempts” in response to an attempt to call CreateShellStream.

After some debugging I found out that in ChannelSession.cs “private void SendChannelOpenMessage()” ends up setting LocalPacketSize as 65536.
For some reason that switch seems to operate on signed ints and only allows maximum value of 32768. Anything above that and the channel creation error is guaranteed.

For my use I can setup needed correction in source, but could there be a generic way to setup the value in the creation of ShellStream?
Also this servers as FYI for anyone hitting their head against the same problem.

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 ChannelSession.cs and its private SendChannelOpenMessage() method, then trace how CreateShellStream creates the channel. Investigate how LocalPacketSize is set and how a caller could provide a smaller value for servers with this limitation. Done means the channel can be created with a compatible packet size without breaking the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.