Table of Contents

Method GetClientAsync

Namespace
SshSharp.Extensions.DependencyInjection
Assembly
SshSharp.Extensions.DependencyInjection.dll

GetClientAsync(string, CancellationToken)

The connected client for name: the shared one if it is still up, otherwise a new connection, which then becomes the shared one. Concurrent callers share one attempt. After a failed attempt the next one waits (from ReconnectDelay, doubling, up to MaxReconnectDelay); a call made during that wait fails at once, with an SshException whose inner exception is the last failure, rather than connecting again.

Task<SshClient> GetClientAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string
cancellationToken CancellationToken

Returns

Task<SshClient>

Exceptions

InvalidOperationException

No endpoint is registered as name.

OptionsValidationException

The endpoint's settings are invalid.

SshException

The connection or authentication failed, now or (as its inner exception) in the last attempt.

TimeoutException

The attempt took longer than ConnectTimeout.