Reputation: 165
My problem is for how do i test a Webrequest timeout . My C# code is making a SOAP service call to a 3rd party vendor whose code i do not have . When their service goes down , most of my application URLs also go down as well.
So I thought of adding a timeout ; and read this blog as well which was helpful , but what would be the best way to test my code ?
Adjusting HttpWebRequest Connection Timeout in C#
Upvotes: 2
Views: 2709
Reputation: 460
I had the same problem and solved it using https://httpstat.us/
In my case I needed a 60 secs timeout so I made my request to https://httpstat.us/200?sleep=120000 and it worked.
Posted in case it is useful for anyone.
Cheers.
Upvotes: 4
Reputation: 109
You can build a wrapper around the third part call and use the interface to mock your calls made to the third party so that you can return what you are expecting.
Upvotes: 0
Reputation: 1062
Try connecting to an existing internet address but without using a standard port - a port where no service is running. This way the firewall should drop the packet and you should receive a timeout.
Eg. Use one of the big internet players but instead of port 80 (http) or 443 (https) use 354
Upvotes: 0