You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a server based on ssh2 and ssh2-streams package. During uploading files, we are pushing data to a readable stream which is consumed by some other method. Is there a way to communicate to client to stop sending any more data when our readable stream's buffer is full?
I have observed that if we don't send the OK response from the write event handler from server, the client stops sending data after like 60 chunks and waits for OK response for corresponding requestId's before sending any more data.
In the previous version of ssh2 , we were doing something like this:
I am not sure but the above code must have caused the sftpStream to go in paused mode when calling this.sftpStream.pause() and it might have stopped sending response back to client until this.sftpStream.resume() is called, switching back the sftpStream into flowing mode.
Since the new version of ssh2 is released, we don't have pause and resume methods available on this.sftpStream.
We have modified the code something like this:
const myReadable = new MyReadable({}, this.sftpStream);
this.sftpStream.on('WRITE', (requestId, handle, offset, data) => {
if (!myReadable.pushData(data))
return myReadable.pushToPending(requestId)
this.sftpStream.status(requestId, SFTP_STATUS_CODE.OK)
});
Can you please give me suggestion on if it is a good way to handle such scenario or some better way exists?
Is there a way to send a message from server to client to pause and resume the upload?
Thanks
The text was updated successfully, but these errors were encountered:
We have a server based on ssh2 and ssh2-streams package. During uploading files, we are pushing data to a readable stream which is consumed by some other method. Is there a way to communicate to client to stop sending any more data when our readable stream's buffer is full?
I have observed that if we don't send the
OK
response from the write event handler from server, the client stops sending data after like 60 chunks and waits forOK
response for corresponding requestId's before sending any more data.In the previous version of
ssh2
, we were doing something like this:I am not sure but the above code must have caused the sftpStream to go in
paused
mode when callingthis.sftpStream.pause()
and it might have stopped sending response back to client untilthis.sftpStream.resume()
is called, switching back the sftpStream into flowing mode.Since the new version of
ssh2
is released, we don't havepause
andresume
methods available onthis.sftpStream
.We have modified the code something like this:
Can you please give me suggestion on if it is a good way to handle such scenario or some better way exists?
Is there a way to send a message from server to client to pause and resume the upload?
Thanks
The text was updated successfully, but these errors were encountered: