ssh2-streams
ssh2-streams copied to clipboard
Piping sftp readStream to sftp writeStream - no error when client disconnects
Hi, I'm copying files via sftp from one server to another simply by piping a readStream to writeStream. Actually I'm using ssh2-promise, but afaict, it simply wraps ssh2-streams methods.
Unfortunately, it seems copying hangs forever, when (say) the destination server disappears. Debug output says
DEBUG: Outgoing: Writing CHANNEL_CLOSE (0) and later DEBUG: Outgoing: Writing REQUEST_FAILURE
every 15 seconds. When the source server disappears instead, I don't see a channel close, but outgoing write fails with the same DEBUG message.
Furthermore, when I want to cancel a copy task, closing ssh2 connection does not seem to stop/error the streams.
How should I handle these cases?
Well, nevertheless it might be an ssh2-promise issue (see linked issue).
Hmmm - is it a bug, that not the readStream emits the error, but SSH2.Client?
If there are outstanding requests for an sftp session when it's cleaned up, errors are passed to the requests' callbacks, which should in turn emit errors on the stream.