-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading data returns only empty buffer #1162
Comments
Can you provide some minimal code to reproduce this issue, especially the server side? |
Thanks, yes, sure. Server-side is pure ssh2, while client side is ssh2-promise which probably will not help much. Server side:
Client side:
In client, dstSftp.write fails, because buffer in r[1] has length zero. Don't know if this is sufficient. Runnable code would be harder, though. One thing I didn't mention: Client worked without issue until I updated ssh2 from 0.8.9 to 1.9.0. And if I replace |
What is |
I tried |
It's only a small file: 3289 Bytes - also concurrency is 1 for this test. However, I tried larger files, with the same result. |
I tried this little test program against openssh-sftp-server (Debian 1:8.4p1-5), reading another (arbitrary) file of 15706 bytes length.
using ssh2@^1.9.0. Here's the output:
This looks like the same problem: although 15706 bytes are read, the buffer is empty. The same test program with ssh2 0.8.9 gives this output:
|
This should be fixed now. |
Great, thank you! |
Do you have an estimation when the fixed version will be release on npm? |
@mscdex I'm afraid this issue should be reopened. Actually it's another bug, but related. Say, I have a chunksize of 32kb (that does not seem to be effective, because of the small "overflow" package of 816 Bytes - in fact, I'd like to use 2*31952 - but the explanation will be more clear). Such, the client reads 31952 Bytes, and then 816 Bytes. It's obvious, that the client needs the server to ask for 816 Bytes starting at 31952 (see https://github.com/mscdex/ssh2/blob/master/lib/protocol/SFTP.js#L2004). However, the client should use 0 in the callback, not 31952 as in the request (see https://github.com/mscdex/ssh2/blob/master/lib/protocol/SFTP.js#L2015). So you probably need something like OrigPos in addition to OrigOffs. BTW, if the chunkSize is larger than 2*31952 it looks to me as if read_ fails even more (TM): for chunkSize of 64kb (with overflow 1632), the position reported in the callback is 63904... |
Hmmm, may be. I don't know how fastGet works though: does it use read_? and if so, why wasn't it affected from this issue (here)? The (somewhat :-)) fixed version hasn't been released yet, afaict. I'm using a dependency on the git repo. BTW, I tried the "origPosition" approach (no PR yet):
Looks good to me so far. Would you please check? |
Although I'm using ssh-promise as a wrapper, this issue is not related as far as I can tell.
I'm connecting to a server that's written using SSH2 as well. When I try to read some file (3289 Bytes) I can see the server filling buffers, but in the client they are returned empty.
I followed until https://github.com/mscdex/ssh2/blob/master/lib/protocol/SFTP.js#L2013, where req.nb is 0, so bufferSlice creates an empty buffer for data.
The file I try to read is 3289 Bytes, my buffer is 32kB, so req.nb is initialized with 0 and never changed.
nb is the correct size of the file, len is the size of the buffer (32kB). overflow is 816 (what does it mean?). data (incoming in cb) does contain the correct file contents.
So what might be wrong here? Why is data (outgoing) empty?
The text was updated successfully, but these errors were encountered: