Error using ftp/mget Read timed out
20 ビュー (過去 30 日間)
古いコメントを表示
Brandon Sloan
2017 年 9 月 3 日
コメント済み: Ian Garrick-Bethell
2023 年 1 月 2 日
Hello, I am downloading large satellite rainfall datasets from a NASA ftp and keep running into a timeout issue when using the function mget. This issue arises when I try to access one folder in particular. This folder takes around 1 minute to display its contents when I access it manually through a web browser, so I think the solution is to just increase the timeout for mget, which I do not know how to accomplish. Below is the the loop I use to download from the ftp along with the accompanying timeout error I get. Additionally I am using MATLAB R2015b. Thanks in advance
%%Code for downloading the Surface Temperature (gprof) and Radar Precipitation (dpr) data from the GPM Satellite
clc
clear
clear classes % Not sure why I need this but sometimes the code will not run without it.
% Initiate connection to the ftp server
username = 'xxxxxxxxxxx';
password = 'xxxxxxxxxxx';
ftpobj = ftp('arthurhou.pps.eosdis.nasa.gov',username,password);
pasv(ftpobj) % Allows passive mode FTP (https://www.mathworks.com/matlabcentral/fileexchange/6626-passive-mode-ftp-in-matlab)
% Set the timeframe of the data that needs to be collected
year= '2015';
month = {'02'};
for i=1:size(month,2)
day=dir(ftpobj,['/gpmdata/',year,'/',month{i}]); % to obtain numbers of days in that month
for k=1;
path_ftp = ['/gpmdata/',year,'/',month{i},'/',day(k).name];
path_env = '/radar/2A-ENV.GPM.DPR*.HDF5';
mget(ftpobj,[path_ftp,path_env],'C:\Users\sloan091\Documents\PhD\ExtremeRainfallAnalysis\Matlab\Brandon_Codes');
end
end
Error using ftp/mget (line 32)
Java exception occurred:
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at org.apache.commons.net.ftp.FTPClient.listNames(FTPClient.java:1957)
0 件のコメント
採用された回答
Walter Roberson
2017 年 9 月 3 日
hs = struct(ftpobj);
old_timeout = hs.jobject.getConnectTimeout; %if you want to query
hs.jobject.setConnectionTimeout(50); %or as appropriate
Note: you cannot access the jobject field of ftpobj directly: you must struct() it to bypass the type security.
2 件のコメント
Ian Garrick-Bethell
2023 年 1 月 2 日
I get the following error when attempting this solution in Matlab 2022 for Windows:
"Unrecognized field name "jobject"."
Is there a new solution to setting the connection timeout time? Thanks!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で FTP File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!