Skip to content

Timeout does not seem to have desired effect #1697

Open

Description

@paalandreassen

SSH.NET 2025.0.0

I'm executing a command on a ssh session to a router that takes some time to complete. I get a System.Exception after 30 seconds no matter what I've set timeouts to:

long_running_script.sh:

#!/bin/sh
echo Simulating a long running operation
sleep 45
echo Done

short_running_script.sh:

#!/bin/sh
echo Simulating a quick operation
sleep 5
echo Done
var sshClient = new SshClient("192.168.1.1", "root", password);
sshClient.ConnectionInfo.Timeout = TimeSpan.FromSeconds(60);
sshClient.ConnectionInfo.ChannelCloseTimeout = TimeSpan.FromSeconds(60);
sshClient.Connect();

var cmd = sshClient.CreateCommand(". /home/user/long_running_script.sh");
cmd.CommandTimeout = TimeSpan.FromSeconds(60);
var res = cmd.Execute();

This throws a generic System.Exception after 30 seconds. No further information, no inner exception. If I call short_running_script.sh instead it works fine.

Activity

  1. mus65 commented on Sep 6, 2025

    @mus65
    Contributor

    Do you have a stacktrace? I can't reproduce this. I also can't find any place in the codebase where an empty System.Exception is thrown (aside from test cases).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions