Skip to content

ShellStream.Expect TimeSpan timeout, not working. #714

Closed

Description

@gavin1970

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));

Activity

  1. gavin1970 commented on Aug 7, 2020

    @gavin1970
    Author

    I ended up, just threading off the writeline / expect then handled the timer with an EventWaitHandle.

  2. IgorMilavec commented on Feb 24, 2022

    @IgorMilavec
    Collaborator

    I have created a discussion #926 for all ShellStream related issues.

  3. IgorMilavec commented on Mar 21, 2022

    @IgorMilavec
    Collaborator

    @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?

  4. biocoder-frodo commented on Jun 15, 2023

    @biocoder-frodo

    @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

  5. WojciechNagorski commented on Feb 22, 2024

    @WojciechNagorski
    Collaborator

    This issue has been fixed in the 2024.0.0 version.

  6. added this to the 2024.0.0 milestone on Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions