It is a little bit misleading error message. It is true, that the terminal is not bound to a channel, however the real cause is probably that the terminal was unbound due to loss of connection.
The terminal is not bound to a channel in 4 cases:
- a new instance of terminal, which was never bound
- an instance on which
Unbind
method was just called
- an instance on which
Dispose
method was called
- an instance, which underlying channel was undound due to connection loss
From your description, we can eliminate point 1 (ssh.StartVirtualTerminal()
creates bound terminal).
If you are sure that you didn't call Unbind
or Dispose
methods before you call SendToServer
method, the last possible explanation is point 4.
Basically, it can arises in 3 situations:
- connection close was requested by client e.g. by issuing
exit
command
- connection was close forcibly by server e.g. the server encountered an error and closed the existing connection
- connection was interrupted due to network failure
To detect any of the above connection closures please use the VirtualTerminal.Disconnected
event.
However, I improved exception message to better describe the situation (EDIT: it was included in release 2017 R2).
If you have doubts about the cause of error in your case, please send us the Debug
log of your communication (to support@rebex.net). I will analyze it for you.