Http Timeout webread not working

26 views (last 30 days)
Tobias Wagner
Tobias Wagner on 7 Nov 2022
Edited: VINAYAK LUHA on 11 Oct 2023
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.

Answers (1)

VINAYAK LUHA
VINAYAK LUHA on 11 Oct 2023
Edited: VINAYAK LUHA on 11 Oct 2023
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

Products

Community Treasure Hunt

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

Start Hunting!