specifying 'Timeout' in weboptions does not work
Show older comments
Hi all!
I want have a 1 sec. timeout in my call to webwrite(). However, this code takes 30 sec. to execute before throwing an error.
webwrite('http://dummy', 'blah', weboptions('Timeout', 1))
What is even more weird, is that the call to "weboptions" without arguments shows that the default is 5 sec. (returns "Timeout: 5")
I am running Matlab 2015a, on OS X 10.10
Any idea, what could be the problem?
Answers (1)
Rahul
on 24 Jun 2025
I understand that you wish to set a 1 second timeout before throwing an error while using 'webwrite' for the dummy url. You are experiencing a delay of 30 seconds before the error is being thrown.
The following behaviour is observed because:
- 'http://dummy' triggers a DNS lookup, which fails slowly (up to 30 seconds), especially if the domain doesn’t exist.
- The 'Timeout' value (even if set to 1 second) is ignored during DNS resolution.
As a workaround to test the 1 second timeout, consider using a non-routable IP address. This would bypass the DNS step and trigger the TCP timeout.
Here is an exmple:
webwrite('http://10.255.255.1', 'blah', weboptions('Timeout', 1));
The following MathWorks documentations can be referred:
Thanks.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!