Linux “php_connect_nonb() failed: Operation now in progress (115)” 间歇性发生
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15688331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"php_connect_nonb() failed: Operation now in progress (115)" happens intermittently
提问by Mikey C
We send some files across to a third party with a PHP cron job via FTP.
我们通过 FTP 使用 PHP cron 作业将一些文件发送给第三方。
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.
当我说“有时”时,我的意思就是这样;大多数时候它都很好,但大约五分之一的时候我们会遇到这个错误。这与文件本身无关,因为如果我们再试一次,它们会很高兴。
We've found similar issues online - relating to a bug in PHPwith NAT devices or to do with firewall configuration but again the implication is that if this were the case it would neverwork.
我们在网上发现了类似的问题——与带有 NAT 设备的PHP 中的错误有关,或者与防火墙配置有关,但同样的含义是,如果是这种情况,它将永远无法工作。
So, why would this work some times and not others?
那么,为什么这有时会起作用,而其他时候不起作用?
回答by ariestav
So, I'm writing this answer after doing some investigation on my FTP server and reading the link you provided elitehosts.com.
因此,我在对我的 FTP 服务器进行了一些调查并阅读了您提供的elitehosts.com 链接后写下了这个答案。
I'm using FileZilla FTP server, and there is a specific setting that I had to enter to make it work. Going into the server settings, there is an area titled "Passive mode settings". In that dialog, there is an area titled "IPv4 specific", and within that area there is a setting labeled "External Server IP Address for passive mode transfers:". It's a radio button selection set, and it was on "Default", but since the FTP server is NAT'ed, I changed that radio selection from "Default" to "Use the following IP:" and entered in the external-facing IP address of my gateway provided by my ISP.
我正在使用 FileZilla FTP 服务器,我必须输入一个特定的设置才能使其工作。进入服务器设置,有一个标题为“被动模式设置”的区域。在该对话框中,有一个标题为“IPv4 特定”的区域,在该区域中有一个标记为“用于被动模式传输的外部服务器 IP 地址:”的设置。这是一个单选按钮选择集,它在“默认”上,但由于 FTP 服务器是 NAT'ed,我将该单选选项从“默认”更改为“使用以下 IP:”并输入到面向外部的 IP我的 ISP 提供的网关地址。
After I set this up, it worked! Not terribly sure if your FTP server is NAT'ed, but I thought I would provide the answer on this thread because it seems related.
我设置后,它起作用了!不太确定您的 FTP 服务器是否经过 NAT,但我想我会在此线程上提供答案,因为它似乎相关。
回答by Cees Timmerman
FTP(S) uses random ports to set up data connections; an intermittent success rate indicates that not all ports are allowed by a firewall on the client and/or server machines. The port range for incoming (PASV) data connections can be set in the FTP server.
FTP(S) 使用随机端口建立数据连接;间歇性成功率表示客户端和/或服务器计算机上的防火墙并非允许所有端口。传入 (PASV) 数据连接的端口范围可以在 FTP 服务器中设置。
This pagehas a nice summary:
这个页面有一个很好的总结:
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!
简单的方法是简单地允许 FTP 服务器和客户端通过防火墙无限制访问,但是如果您想限制他们对“已知”端口的访问,则必须了解 4 种不同的情况。
1) 应该允许 FTP 服务器接受到端口 21 的 TCP 连接,并从端口 20 到任何(远程临时)端口进行 TCP 连接。
2) 应该允许 FTP 服务器接受到端口 21 的 TCP 连接,并且也接受到任何临时端口的 TCP 连接!
3) 应该允许 FTP 客户端与端口 21 建立 TCP 连接,并接受从端口 20 到任何临时端口的 TCP 连接。
4) 应该允许 FTP 客户端与端口 21 建立 TCP 连接,也可以与任何其他(远程临时)端口建立 TCP 连接!
回答by Oliver Watts
In addition to Cees answer, I am running vsftp on ec2 and had to comment out the listen_ipv6=YES, listen=YES then "service vsftpd restart".
除了Cees 的回答,我在ec2 上运行vsftp 并且不得不注释掉listen_ipv6=YES,listen=YES 然后“service vsftpd restart”。
Although documentation says it will listen on ipv4 as well it wasn't and this resolved the issue.
尽管文档说它也会在 ipv4 上收听,但事实并非如此,这解决了问题。
回答by jj_dev2
ftp_set_option($ftpconn, FTP_USEPASVADDRESS, false);
This line of code before setting passivity of the connection ftp_pasv($ftpconn, true);
设置被动连接前的这行代码 ftp_pasv($ftpconn, true);
Solved my problem
解决了我的问题