"timeout" setting not work in webread function

10 Ansichten (letzte 30 Tage)
Yu Li
Yu Li am 13 Sep. 2024
Beantwortet: Debadipto am 16 Sep. 2024
Hi:
I use parallel loop to grab data using "webread" , I set up the timeout option to be 10 seconds,
options = weboptions;
options.Timeout = 10;
then use command like below:
timeCost=[];
parfor i=1:1:1e4
tic
webReadTmp=webread(command,options);
timeCost(i)=toc;
end
I use "timeCost" variable to record the time needed for each webread operation. however I notice there are some webread cost more than 30 second, which means the "timeout" setting is not working here.
is there any mistake with my command?
Thanks!
Yu

Antworten (1)

Debadipto
Debadipto am 16 Sep. 2024
Hi @Yu,
The "Timeout" setting here specifies the maximum duration to wait for an initial response from the server after sending a request, not an estimate of how long it will take to receive the full response. If the server responds within the timeout duration, you will receive the response; otherwise, a timeout error occurs. It is a safeguard to prevent waiting indefinitely for a response.
In summary, the timeout does not estimate the response time but sets a limit on how long you are willing to wait for a response.
For the definition of "Timeout", please refer to the following MATLAB documentation:
https://www.mathworks.com/help/matlab/ref/weboptions.html#:~:text=Timeout%20%E2%80%94%20Time%20out%20connection%20duration

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by