Property OperationTimeout
OperationTimeout
How long a request may go unanswered while the server sends nothing at all, before it fails with an SshException (Timeout, with a TimeoutException inside). The default, InfiniteTimeSpan, waits for as long as the session lasts.
public TimeSpan OperationTimeout { get; set; }
Property Value
Remarks
The limit is on the server's silence, not on how long an operation takes: while the server keeps answering other requests (a
transfer's window of reads or writes on a slow link, or other callers on this session), a request waits on, so a large file is
never cut off for its size. A server or link that has stopped answering fails every waiting request once this much time has
passed without a reply. That includes a request still being sent: when the server stops reading (its sftp-server hangs
while sshd still answers keep-alives), the channel's flow-control window fills and a write cannot go out. It applies to every
request, those of transfers, streams and listings included; the CancellationToken each method takes still works
alongside it, and cancelling is an OperationCanceledException, never a timeout.
A request that timed out waiting for its reply is abandoned, not undone: the server may still carry it out, and its late reply is dropped (a handle it opens is closed). The session stays usable. A request that timed out while it was being sent closes the session instead (IsConnected becomes false), since part of it may have gone out and nothing could follow it: every request waiting on the session fails with the timeout, and a new session is needed. That holds for a send whose caller cancelled too: the caller stops waiting, and the send left in the background is still bounded. It can be changed at any time; requests already waiting keep the value they started with. A segmented transfer's extra sessions (Segments) take this session's value.
The silence is measured from the last reply this client has read off the session, on the connection's clock. So time in which this process could not run at all (suspended, or so overloaded that its threads did not get to run) counts as silence, even if the server answered meanwhile: its replies wait in the network buffers until the process runs again, and when it does, the timeout's check can come before they are read. Choose a timeout well above the longest stall your application may have; it is meant for seconds to minutes, not milliseconds.
Exceptions
- ArgumentOutOfRangeException
Not positive and not InfiniteTimeSpan, or longer than MaxValue milliseconds.