-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
Error when downloading file - Expected NET_SFTP_DATA or NET_SFTP_STATUS. Got packet type: #1654
Comments
Can you get me the SSH logs? You're already doing That's more helpful because what's prob going on is that there's some sequence of packets that's causing things to get messed up. Thanks! |
@terrafrost One more thing, since am downloading media files one-by-one in a loop, when this exception is thrown, for next file it gives |
So phpseclib is sending 32x SSH_FXP_READ packets at a time and is expecting 32x SSH_FXP_DATA or SSH_FXP_STATUS packets in response. The 32 is configurable through the NET_SFTP_QUEUE_SIZE constant. Each successive SSH_FXP_DATA packet is requesting 32kb at a time with the offsets increasing by 32kb with each request. The last SSH_FXP_READ packet your server is responding to is requesting 32kb of data that's 4,674,158,592 bytes into the file. It responds to that request without issue but then when processing the request for data 4,674,191,360 bytes in it kills the channel. If there isn't data available beyond that offset what it should do is respond with an SSH_FXP_STATUS message. Quoting https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.4:
That's not what your server is doing. You can probably reproduce this more simply by doing this: $sftp->get(
'/sfa/mediaarchive/profile5/feature/BM_44431_hd_h264_p005.ts.gpg:N0CUN',
0x1169a8000,
0x8000
); (idk that I'm also curious to know what you're using for your SSH server. You can get that by doing Anyway, lmk about my hypothesis for If my hypothesis pans out then get me the logs and I'll use those logs to develop / test a fix. Thanks! |
Actually the server am accessing is not our own, it's a server of Media Content Provider from where am downloading the media files for processing and the issue is not specific to a file, its random. Server Identification is: SSH-2.0-CrushFTPSSHD I've tried to reproduce this issue with the get method you've provided but file got downloaded successfully so as I said it's random
Also, If you'll notice there is difference in filesize by 32Kb
And If I echo filesize echo $sftp->filesize('/mediaarchive/profile5/feature/BM_44431_hd_h264_p005.ts.gpg') outputs 5164221471. |
So I actually gave you the wrong command to try lol. Try this: $sftp->get(
'/sfa/mediaarchive/profile5/feature/BM_44431_hd_h264_p005.ts.gpg',
false,
0x1169a8000,
0x8000
); That said, I did download and install SSH-2.0-CrushFTPSSHD and tried my own test: $sftp->delete('dummyfile');
$sftp->put('dummyfile', str_repeat('a', 10));
$str = $sftp->get('dummyfile', false, 100, 32); I wasn't able to reproduce the behavior your seeing with that script. I have an idea for a change that I think will "fix" the issue for you (altho there is a case to be made that the problem is with SSH-2.0-CrushFTPSSHD and not phpsclib but whatever) but in lieu of being able to reliably reproduce the issue I won't be able to test it. Anyway, I'll try to work on my idea in the next day or two. Thanks! |
Thanks, I've tried with the new command you've provided and it didn't throw/raised any exception but status was failed. lol, since this thing is really getting on my nerve, I've tried downloading these media files via Python (pysftp & paramiko) but both were complete failure. I'm not sure whether this random issue is getting caused by having multiple (~10) ssh sftp sockets open to download media files concurrently or not but I'll try to download these media files sequentially one-by-one and will see if this issue occurs or not. |
Does https://github.com/terrafrost/phpseclib/tree/3.0-channel-closure fix the issue for you? |
Thanks. I would like to ask two thing,
|
I'm not sure why anyone would want to?
Re-keying is recommended every 1h or after every 1GB. phpseclib doesn't initiate re-keying itself - rather, it relies on the server to initiate it. But in this case, no, the server isn't sending any rekey requests based on the logs you provided. If it was expecting one (as opposed to initiating one) then I'd expect the whole connection - and not just the channel - would be closed. |
Thanks @terrafrost Branch 3.0-channel-closure solved the issue. So, far able to download 500+ Media Files from SFTP server each file 5GB+. |
The change for this is live: I did make a few tweaks to what I did in the 3.0-channel-closure branch, so I'd switch to the 3.0 branch, instead. Thanks! |
Hi @terrafrost
I'm getting the same issue #1555 when trying to download large media files (~4-7GB) from our client's SFTP Server. Some of the files are getting downloaded successfully but for some, getting this error/exception
I'm using phpseclib - 3.0.8
On debugging, SSH Error logs shows nothing but SFTP error logs shows
Sample code from the script
Attached entire stack trace
nohup.txt
The text was updated successfully, but these errors were encountered: