You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ShellStream.Expect TimeSpan timeout, not working. #714
Microsoft Visual Studio Professional 2019 Version 16.6.5
.NET Framework 4.7.2
SSN.NET v2016.1.0
I'm using the latest SSH.NET with ShellStream and when calling the Expect(Regex, TimeSpan) the timeout doesn't seem to work at all. I've also tried using TimeSpan.FromSeconds(30) with the same results. If the expected information comes back, it works fine.
this.shellStream.WriteLine(command);
var expectRegex = new Regex(@"\[(.*?)\][$#]|[$]");
var output = this.shellStream.Expect(expectRegex, new TimeSpan(0, 0, 30));
@gavin1970 at this time the implementation resets the timeout after each byte received. This is definitely something we need to look into.
I'm trying to better understand usage patterns related to Expect API. Can you please explain how you use it and if possible provide a proto code for it?
Activity
gavin1970 commentedon Aug 7, 2020
I ended up, just threading off the writeline / expect then handled the timer with an EventWaitHandle.
IgorMilavec commentedon Feb 24, 2022
I have created a discussion #926 for all ShellStream related issues.
IgorMilavec commentedon Mar 21, 2022
@gavin1970 at this time the implementation resets the timeout after each byte received. This is definitely something we need to look into.
I'm trying to better understand usage patterns related to Expect API. Can you please explain how you use it and if possible provide a proto code for it?
biocoder-frodo commentedon Jun 15, 2023
@IgorMilavec I'm using it in https://github.com/biocoder-frodo/VPNCenter.OpenVPN.PackageConfig and https://github.com/biocoder-frodo/SynoDuplicateFolders to be able to do an interactive sudo command inside an SSH session. I quickly realised that the Regex should be really simple. If you constrain the expression too much, you have no or not enough guarantees that the incoming network stream will deliver the text in the chunk(s) that you need for the Regex to match.
So I chose to respond only to the patterns my host will throw at you when try to run a command using sudo.
For example:
https://github.com/biocoder-frodo/DiskStationManager.SecureShell/blob/11a78f754067ea1ec8e8cbb3420855f6a1044e5b/source/DiskStationManager.SecureShell/SudoSession.cs#L135
WojciechNagorski commentedon Feb 22, 2024
This issue has been fixed in the 2024.0.0 version.