PHP : Net_SFTP library, unable to download big files

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

PHP : Net_SFTP library, unable to download big files

Postby ehussain » Tue Jan 17, 2012 3:16 am

Hello,

I am working on a PHP project which has to deal with large attachment files. I am using SFTP server for storage of such big files. For uploading and downloading attachment files I am using Net_SFTP library (http://phpseclib.sourceforge.net).

Upload is working fine. But download functionality works fine only for the files for which file size is limited to 20 MB. But if my file size is larger than 20MB then my download gets stuck at 21672 Bytes (~20.7 MB) and it returns the empty file when SFTP timeout occurs.

I have already checked memory_limit, max_execution_time and sftp timeout limit of php but it didn't helped.

Please help!

eHussain
ehussain
Traveler
 
Posts: 1
Joined: Tue Jan 17, 2012 3:14 am

Re: PHP : Net_SFTP library, unable to download big files

Postby TerraFrost » Thu Jan 19, 2012 2:01 am

I guess the first question I have is... is the second parameter of get set? It sounds like it is but I'd just like to make sure.

Can you download files 20MB+ with other SFTP clients?

Also, if you could give me, via PM, an SFTP account on your SFTP server so that I might reproduce the problem, myself, that'd assist in diagnosing it!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: PHP : Net_SFTP library, unable to download big files

Postby TerraFrost » Fri Jan 20, 2012 6:52 am

I made a change that might affect this. If you could try it out and let me know that'd be great. Thanks!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: PHP : Net_SFTP library, unable to download big files

Postby mitodna » Tue Sep 10, 2013 3:37 am

same issue

using phpseclib 0.35, using with php command line version 5.4.8 on SunOS
there is no error log, it is just stuck at ~20MB.
mitodna
Traveler
 
Posts: 4
Joined: Tue Sep 10, 2013 3:32 am

Re: PHP : Net_SFTP library, unable to download big files

Postby TerraFrost » Tue Sep 10, 2013 1:29 pm

Well this is certainly an older thread.

Based on the dates of the last my guess would be that the commit I was referring to then was this one:

https://github.com/phpseclib/phpseclib/ ... 96ddb338e0

Per that link though that commit is in 0.3.5. It's also in 0.3.1 and 0.3.0, so that's not your issue.

Anyway, three things.

  1. I'd recommend always using the latest Git version when you encounter a problem with the latest release version.
  2. Can you get me logs? eg. after "include('Net/SFTP.php');" do this:

    Code: Select all
    define('NET_SSH2_LOGGING', NET_SSH2_LOG_REALTIME_FILE);
    define('NET_SSH2_LOG_REALTIME_FILENAME', 'phpseclib.log');

    ... and then post phpseclib.log.
  3. Can you download "big files" with any other SFTP client?
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: PHP : Net_SFTP library, unable to download big files

Postby mitodna » Tue Sep 10, 2013 5:03 pm

Hi,
I am using the latest git version as well.
Attached is the log in compressed rar.
I can download with the other SFTP client.

Thank you.
Attachments
phpseclib.rar
(460.32 KiB) Downloaded 120 times
mitodna
Traveler
 
Posts: 4
Joined: Tue Sep 10, 2013 3:32 am

Re: PHP : Net_SFTP library, unable to download big files

Postby TerraFrost » Wed Sep 11, 2013 6:14 am

Two questions.

  1. What is the server identification string? You can get that by doing $ssh->getServerIdentification().
  2. How big is the file on the remote filesystem and how big is the file on the local filesystem after the hang happens?
    (what I'm wondering is if the entire file is being downloaded and if it's just sorta waiting for nothing - ie. more of the file to be sent when the whole file has already been sent)
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: PHP : Net_SFTP library, unable to download big files

Postby mitodna » Wed Sep 11, 2013 5:18 pm

Hi,

The server identification string: SSH-1.99-OpenSSH_4.1

Remote files around 33MB, the local file hang around 22151168 bytes
It is just one file, when I run it, I saw the file is growing, and it just hang 22151168 bytes, I waited for 5 minutes, it didn't increase, so I had to kill the task

Thank you.
mitodna
Traveler
 
Posts: 4
Joined: Tue Sep 10, 2013 3:32 am

Re: PHP : Net_SFTP library, unable to download big files

Postby norbyte » Wed Sep 11, 2013 6:29 pm

Sounds like you have the same problem like me: http://www.frostjedi.com/phpbb3/viewtopic.php?f=46&t=168873

As a workaround (which was working for me):

If you use phpseclib 0.3.0: Open SFTP.php and replace "1 << 20" with "1 << 15".
If you use phpseclib 0.3.5: Open SFTP.php, find "ROSSSH", then add a case with your server identifier string to use the fallback to set "$this->max_packet_size = 1 << 15"
norbyte
Traveler
 
Posts: 2
Joined: Wed Sep 11, 2013 9:57 am

Re: PHP : Net_SFTP library, unable to download big files

Postby mitodna » Thu Sep 12, 2013 8:48 am

Hi TerraFrost, Hi norbyte,
The workaround works.
Thank you.
mitodna
Traveler
 
Posts: 4
Joined: Tue Sep 10, 2013 3:32 am


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest

cron