Closed clsource closed 3 years ago
Hi, Thank you for a detailed explanation of your issue. I took a quick look into the Web Watcher and it turns out that it returns an invalid result only if the TaskCanceledException happened.
I thought that this one will occur when there's a timeout but it seems that I was wrong :). I'll need to think how to fix this, as I'd rather do not change the current behavior of these 2 system exceptions (make them trigger OnError), but the timeout shouldn't be treated this way for sure.
Server watcher most likely works the same way but you can give it a try.
I'm glad that you like this library, thanks! :)
Replace the line :
.WithTimeout(TimeSpan.FromMilliseconds(3000))
With the line :
.WithHttpServiceProvider(() => new HttpService(new HttpClient() { Timeout = TimeSpan.FromMilliseconds(3000) }))
@tolispy seems like a good workaround :).
Hello I´m trying to create a watcher. What I need is checking if the server went down. This is the code that I´m using.
Basically the code wants to make a request every 15 seconds and if the server does not respond for 3 seconds it must send an alert.
My issue is that if I keep the 3 second timeout the code triggers an
System.InvalidOperationException
(This instance already started one or more requests) associated with the HttpClient. If I remove the 3 second timeout the code triggers anSystem.Net.Http.HttpRequestException
. Both cases triggers only theOnFirstErrorAsync
hook and not theOnFirstFailureAsync
hook. The problem with this is that I cannot configure the timeout and can not trigger the failure hook if the server is down.Should I use the
Server
Watcher instead?.Thanks for any help :+1: and congrats for the great project :100: