dongzhuonao8429 2014-09-22 02:19
浏览 59

PHP ftp_get挂起

I am trying to download a file using FTP in PHP CLI. I have no access to the server where I'm downloading from.

Here's some information about my system.

$ php -v

PHP 5.5.12 (cli) (built: Aug 16 2014 11:36:51) (DEBUG)

$ cat /etc/*-release

NAME="Red Hat Enterprise Linux Server"
VERSION="7.0 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.0"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.0:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.0
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION=7.0
Red Hat Enterprise Linux Server release 7.0 (Maipo)
Red Hat Enterprise Linux Server release 7.0 (Maipo)

Here's the code.

$ftpconn = ftp_connect(FTP_HOST);
ftp_set_option($ftpconn, FTP_TIMEOUT_SEC, 86000);
$ftplogin = ftp_login($ftpconn, FTP_USER, FTP_PASS);
ftp_pasv($ftpconn, true);
$list = ftp_nlist($ftpconn, FTP_PATH);
foreach($list as $file){
    ftp_get($ftpconn, DOWNLOAD_PATH . DIRECTORY_SEPARATOR . $file, $file, FTP_BINARY)
}

When the script hits ftp_get the file is created with the proper name, but then it hangs for the amount of time specified in ftp_set_option. PHP never writes anything to the file.

I have set 777 permission for the root folder where it's located recursively. I'm also running PHP CLI as root.

sudo php /path/to/php/file.php

Is this a problem with PHP being unable to write to the file? Why is it not throwing any errors? When the timeout is reached, the ftp_get function simply returns false.

Help would be greatly appreciated.

  • 写回答

1条回答 默认 最新

  • dongxia9620 2015-05-05 02:06
    关注

    The problem was caused by Amazon AWS instance, certain instances changed the MTU of the network interface.

    The solution was as simple as giving the following command:

    sudo ifconfig eth0 mtu 1500
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)