“php_connect_nonb() 失败:操作正在进行中 (115)"间歇性发生

2022-01-09 00:00:00 ftp linux php

我们通过 FTP 使用 PHP cron 作业将一些文件发送给第三方.

We send some files across to a third party with a PHP cron job via FTP.

但有时我们会收到以下错误:

However sometimes we get the following error:

ErrorException [ 2 ]: ftp_put(): php_connect_nonb() failed: Operation 
now in progress (115) ~ MODPATH/fileop/classes/Drivers/Fileop/Ftp.php [ 37 ]

当我说有时"时,我的意思正是如此;大多数时候它都很好,但大约五分之一的时候我们会得到这个错误.这与文件本身无关,因为如果我们再试一次,它们会很开心.

When I say "sometimes" I mean exactly that; most times it goes across fine but about 1 in 5 times we get that error. It's not to do with the files themselves, because they will go happily if we try again.

我们在网上发现了类似的问题 - 与 PHP 中的错误 与 NAT 设备或与防火墙配置有关,但再次暗示如果是这种情况,它将永远工作.

We've found similar issues online - relating to a bug in PHP with NAT devices or to do with firewall configuration but again the implication is that if this were the case it would never work.

那么,为什么这有时会起作用而其他时候却不起作用?

So, why would this work some times and not others?

推荐答案

ftp_set_option($ftpconn, FTP_USEPASVADDRESS, false);

设置被动连接前的这行代码ftp_pasv($ftpconn, true);

This line of code before setting passivity of the connection ftp_pasv($ftpconn, true);

解决了我的问题

相关文章