2013-03-28 92 views
7

我們通過FTP將一些文件發送給第三方並使用PHP cron作業。「php_connect_nonb()失敗:正在進行中操作(115)」間歇發生

但是有時我們得到以下錯誤:

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

當我說「有時」我的意思正是;大多數時候它都很好,但大約有五分之一我們得到這個錯誤。這與文件本身無關,因爲如果我們再試一次,它們會很開心。

我們發現類似的問題在線 - 關於一個bug in PHP與NAT設備或防火牆配置卻又蘊涵做的是,如果是這樣的話它會從未工作。

那麼,爲什麼這個工作有些時候而不是其他人呢?

+0

什麼是你的FTP服務器的版本?更新它可能會修復該軟件中的錯誤。 https://bugs.php.net/bug.php?id=47110 –

+0

是的,我見過那個。但該用戶似乎根本無法連接。不確定服務器的版本是什麼;我需要從第三方中找出答案。 –

+0

嘗試使用SCP而不是FTP:http://www.hypexr.org/linux_scp_help.php –

回答

1

所以,我在對我的FTP服務器進行一些調查並閱讀您提供的鏈接elitehosts.com後寫了這個答案。

我正在使用FileZilla FTP服務器,並且有一個特定的設置必須輸入才能使其工作。進入服務器設置,有一個標題爲「被動模式設置」的區域。在該對話框中,有一個標題爲「IPv4特定」的區域,在該區域內有一個標記爲「用於被動模式傳輸的外部服務器IP地址:」的設置。這是一個單選按鈕選擇集,它處於「默認」狀態,但由於FTP服務器已經過NAT,因此我將該無線電選擇從「默認」更改爲「使用以下IP:」並輸入到外部IP我的ISP提供的網關地址。

當我設置它後,它的工作!不是非常確定你的FTP服務器是否是NAT,但我想我會在這個線程上提供答案,因爲它似乎相關。

2

FTP(S) uses random ports to set up data connections;間歇成功率表示並非所有端口都被客戶端和/或服務器上的防火牆所允許。傳入(PASV)數據連接的端口範圍可以在FTP服務器中設置。

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!