darkoperator / darkoperator/Posh-SSH
Execution stops after a few New-SSHShellStreams
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
Hey there,
I got a weird issue with a script.
Using Posh-SSH 3.0.8, Powershell 5.1 and 7.3
I'm connecting like this
$Session = New-SSHSession -ComputerName $IP -Credential $Cred -AcceptKey -ErrorAction Stop
then I run a bunch of Invoke-SSHCommand and a Invoke-SSHShellStreamCommand
$stream = New-SSHShellStream -SSHSession $Session
$cli = Invoke-SSHStreamShellCommand -ShellStream $stream -Command "cli json"
followed by another StreamShellCommand to get the required info from the device.
Every New-SSHShellStream is within a separate function and is executed on every beginning of the function.
After X Shell-Streams it stops working (currently trying to find out after how many)
The Powershell session keeps running, but the script stops working. Ctrl+C has no effect, I have to kill the powershell session.
Example:
write-host "leases 1"
$stream = New-SSHShellStream -SSHSession $Session
write-host "leases stream: $stream"
$cli = Invoke-SSHStreamShellCommand -ShellStream $stream -Command "cli json"
write-host "leases cli: $cli"
write-host "leases stream: $stream"
is never reached when it happens
the same function worked earlier in the script without problems.
(when I change the order of the functions it also stops at other functions using New-SSHShellStream)
Surrounded by try-catch I don't get any errors, it just stops and I can wait forever.
When I disconnect the SSH-session and reconnect somewhere in the middle of all those calls the script works till the end.
How to avoid the reconnect, since I never really know when it happens?
Do I have to "close" the streams somehow? Is there something like a connection limit I can increase?
Any ideas on debugging this issue further?
Thanks in advance!
Contributor guide
No contributing guide indexed for this repository
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 by reproducing the hang with repeated New-SSHShellStream calls in the provided PowerShell 5.1 or 7.3 sequence, then compare it with Invoke-SSHStreamShellCommand and session reconnects. Determine whether streams require explicit cleanup or whether a connection limit is involved; done means identifying the trigger and documenting or implementing a reliable way to complete the commands without reconnecting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100