2016-11-04 10 views
0

мне нужно загрузить более 65 файлов на мой хостинг FTP-сервер с RCurl, но я получаю сообщение об ошибке после того, как несколько файлов, которые были загружены:Как загрузить многократные файлы в R, не получив ошибку 421 Слишком много соединений?

< 421 Too many connections (8) from this IP 
* We got a 421 - timeout! 
* Closing connection 291 

Из того, что я вижу в журнале, это говорит Connection #283 to host ftp.myserver.com left intact так, что никакая дополнительная авторизация не требуется, пока соединение не истечет через 15 минут бездействия < 220 You will be disconnected after 15 minutes of inactivity..

По крайней мере, это мое понимание, потому что, по какой-то причине, он повторно отправляет имя пользователя и пароль сразу после для второго файла:

> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/

Я понимаю, что есть кратные запросы на авторизацию (один на один файл), так что я Наводнение сервера.

Есть ли возможность сначала открыть соединение с FTP-сервером, а затем загрузить все файлы? как в FileZilla?

Пожалуйста найти код R я использую:

for(file in list.files(localPath)) { 

    ftpUpload(paste0(localPath,file), userpwd = userpwd, to=paste0("ftp://", ftpPath, file), verbose=TRUE) 

} 

Другой SO член имеет такую ​​же проблему здесь, но это выглядит я уже использую нечто похожее на ответ, предоставленный ему и dosen't работы. Using R to upload many files

Спасибо


EDIT (добавление в журнал):

> for(file in list.files(localPath)) { 
+ 
+ print(paste0("ftp://", ftpPath, file)) 
+ ftpUpload(paste0(localPath,file), userpwd = userpwd, to=paste0("ftp://", ftpPath, file), verbose=TRUE) 
+ 
+ } 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation-1.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#310) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 2 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||44516|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 44516 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#310) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation-1.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.180 seconds (measured here), 1.15 Kbytes per second 
* Connection #310 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation-2.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#311) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 3 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||45077|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 45077 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#311) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation-2.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.207 seconds (measured here), 1.00 Kbytes per second 
* Connection #311 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation-3.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#312) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 4 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||40390|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 40390 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#312) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation-3.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.189 seconds (measured here), 1.12 Kbytes per second 
* Connection #312 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation-4.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#313) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 5 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||46329|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 46329 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#313) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation-4.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.187 seconds (measured here), 1.11 Kbytes per second 
* Connection #313 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation_protected-1.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#314) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 6 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||46556|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 46556 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#314) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation_protected-1.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.186 seconds (measured here), 2.75 Kbytes per second 
* Connection #314 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation_protected-2.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#315) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 7 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||43730|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 43730 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#315) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation_protected-2.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.190 seconds (measured here), 2.69 Kbytes per second 
* Connection #315 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation_protected-3.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#316) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 8 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||43399|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 43399 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#316) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation_protected-3.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
< 226-File successfully transferred 
< 226 0.196 seconds (measured here), 2.61 Kbytes per second 
* Connection #316 to host ftp.mywebsite.com left intact 
[1] "ftp://ftp.mywebsite.com/data/csv/data_private_allocation_protected-4.csv" 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#317) 
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 
< 220-You are user number 9 of 1000 allowed. 
< 220-Local time is now 08:50. Server port: 21. 
< 220-This is a private system - No anonymous login 
< 220-IPv6 connections are also welcome on this server. 
< 220 You will be disconnected after 15 minutes of inactivity. 
> USER [email protected] 
< 331 User [email protected] OK. Password required 
> PASS mypassword 
< 230 OK. Current restricted directory is/
> PWD 
< 257 "/" is your current location 
* Entry path is '/' 
> CWD portfolios 
* ftp_perform ends with SECONDARY: 0 
< 250 OK. Current directory is /portfolios 
> CWD csv 
< 250 OK. Current directory is /data/csv 
> EPSV 
* Connect data stream passively 
< 229 Extended Passive mode OK (|||48536|) 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connecting to 11.22.33.44 (11.22.33.44) port 48536 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#317) 
> TYPE I 
< 200 TYPE is now 8-bit binary 
> STOR data_private_allocation_protected-4.csv 
< 150 Accepted data connection 
* Remembering we are in dir "data/csv/" 
[1] "ftp://ftp.mywebsite.com/data/csv/data_coins_average-1.csv" 
< 226-File successfully transferred 
< 226 0.184 seconds (measured here), 2.77 Kbytes per second 
* Connection #317 to host ftp.mywebsite.com left intact 
* Hostname was NOT found in DNS cache 
* Trying 11.22.33.44... 
* Connected to ftp.mywebsite.com (11.22.33.44) port 21 (#318) 
< 421 Too many connections (8) from this IP 
* We got a 421 - timeout! 
* Closing connection 318 
Error in function (type, msg, asError = TRUE) : 
    Uploading to a URL without a file name! 
+0

Вы пытались закрыть любые открытые соединения ('? CloseAllConnections')? –

+0

Привет, я просто закрыл 'gzcon' с' closeAllConnections() ', но все же у меня есть ошибка« 421 Too many connections ». – Florent

ответ

0

Это временное решение, а не решение моей проблемы, но он работает как шарм. Я создал текстовый файл с командами ftp, а затем запустил Ubuntu ftp с R system().

ftpcommands.txt:

open ftp.mywebsite.com 
user [email protected] mypassword 
lcd ~/R/data/csv 
cd data/csv 
prompt 
mput *.csv 
bye 

Тогда R команда:

system("ftp -n < ~/R/data/ftpcommands.txt") 
0

Похоже, вы открываете для каждого файла новое соединение, которое не является, как протокол Передача файла предназначался для использования. Некоторые различные решения:

  1. Открыть меньше подключений в R кода.
  2. Ограничить максимальное количество одновременных соединений, используемых curl.
  3. Увеличьте допустимый предел одновременных подключений в конфиге FTP-сервер. (Делайте это только тогда, когда это действительно необходимо, как я уже говорил, не открывайте для каждого файла соединения.)

Проверить this detailed answer, чтобы получить лучшее понимание проблемы.Не поймите меня неправильно, хорошо, что производительность имеет несколько больше одного соединения одновременно, но не для каждого файла, это слишком сильно. Большинство клиентов FTP используют 2.

 Смежные вопросы

  • Нет связанных вопросов^_^