Skip to content

Timeout does not seem to have desired effect #1697

@paalandreassen

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.

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