Http Timeout webread not working

21 次查看(过去 30 天)
Hello, I'm running into 5 second timeout although I increased it with this webread:
import matlab.io.xml.dom.*
import matlab.io.xml.xpath.*
weboptions('Timeout',60)
data=webread("http://xxx/values.xml");
doc = parseString(Parser,data);
Output:
GetTankLevels
ans =
weboptions with properties:
CharacterEncoding: 'auto'
UserAgent: 'MATLAB 9.13.0.2085925 (R2022b) Update 1'
Timeout: 60
Username: ''
Password: ''
KeyName: ''
KeyValue: ''
ContentType: 'auto'
ContentReader: []
MediaType: 'auto'
RequestMethod: 'auto'
ArrayFormat: 'csv'
HeaderFields: []
CertificateFilename: 'default'
Error using webread
The connection to URL 'http://xxx/values.xml' timed out after 5.000 seconds. The reason is "Connection timeout after 5099 ms". Perhaps the server is not responding or
weboptions.Timeout needs to be set to a higher value.

回答(1 个)

VINAYAK LUHA
VINAYAK LUHA 2023-10-11
编辑:VINAYAK LUHA 2023-10-11
Hi Tobias,
I understand that your "webread" request terminates with a timeout error despite explicitly setting the timeout time higher using the "weboptions" function.
Here is a solution to resolve the timeout error:
  1. Create a "weboptions" object with timeout set to 60 seconds.
  2. Pass this created object as second parameter to the "webread" function
Further, I've also attached the code snippet for your better understanding:
options =weboptions('Timeout',60)
data=webread("http://xxx/values.xml",options);
I hope you find this solution helpful and the timeout error now stands resolved.
Regards,
Vinayak Luha

产品

Community Treasure Hunt

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

Start Hunting!

Translated by