“php_connect_nonb()失败:正在进行的操作(115)”间歇性地发生

前端之家收集整理的这篇文章主要介绍了“php_connect_nonb()失败:正在进行的操作(115)”间歇性地发生前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们通过FTP将一些文件通过 PHP cron作业发送给第三方.

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

ErrorException [ 2 ]: ftp_put(): PHP_connect_nonb() Failed: Operation 
now in progress (115) ~ MODPATH/fileop/classes/Drivers/Fileop/Ftp.PHP [ 37 ]

当我说“有时”时我就是这么说的;大多数情况下,它很好,但我们得到的错误大约是五分之一.这与文件本身无关,因为如果我们再试一次,他们会很开心.

我们在网上发现了类似的问题 – 与使用NAT设备的bug in PHP相关或者与防火墙配置有关,但这意味着,如果是这种情况,它将无法工作.

那么,为什么有些时候会有效呢?

FTP(S) uses random ports to set up data connections;间歇性成功率表示客户端和/或服务器计算机上的防火墙不允许所有端口.可以在FTP服务器中设置传入(PASV)数据连接的端口范围.

This page有一个很好的总结:

The easy way is to simply allow FTP servers and clients unlimited
access through your firewall,but if you like to limit their access to
“known” ports,you have to understand the 4 different scenarios.

1) The FTP server should be allowed to accept TCP connections to port
21,and to make TCP connections from port 20 to any (remote ephemeral)
port.

2) The FTP server should be allowed to accept TCP connections to port
21,AND to accept TCP connections to any ephemeral port as well!

3) The FTP client should be allowed to make TCP connections to port
21,and to accept TCP connections from port 20 to any ephemeral port.

4) The FTP client should be allowed to make TCP connections to port 21,and to make TCP connections to any other (remote ephemeral) port as well!

猜你在找的PHP相关文章