Closed ishepherd closed 7 years ago
Not researched this (& noob) but my guess is, this was correct when HttpWebRequest
was being used. This does throw WebExceptions but since @vturecek change (efb0c635f265591dc78875bea89bf26ca7600fac) the code is using HttpClient
, I am finding it does not throw these exceptions
Unfortunately, I haven't tested the behavior in all these timeout/protocol/socket exception cases so I don't know the extent of changes needed to HttpExceptionHandler. Please advise...
Looks like there's a line missing that checks for HttpRequestException. We're working on a better way to do this using HttpClientHandlers. We'll get this updated soon. In the meantime, take a look here to see how that works: https://github.com/xinyanmsft/SFStartupHttp/tree/master/src/Libs/Microsoft.ServiceFabric.Http/Client
Thanks for reply @vturecek
It takes more than a missing line to fix this example. As this HttpRequestException tells me basically nothing ... unless I want to string match on its (localized!) Message.
But thanks a lot for the full example to check out. I will come back to this next month.
We've switched HTTP communication to use the SF reverse proxy, which we recommend over resolving service endpoints manually. We still have an example of that for reference though in our Service Fabric IoT sample
re WordCount.WebService.HttpExceptionHandler - Which version of which HttpClient are you using, that gives you HttpWebResponses and throws WebExceptions?
For example with a request of mine returning a 404 -
HttpClient.PostAsync
returns me aTask<HttpResponseMessage>
and nothing is thrown. I can access theResult
, still nothing is thrown. I have to callEnsureSuccessStatusCode()
on the result if I want something thrown, and this only ever throwsHttpRequestException
, which is not what yourHttpExceptionHandler
is looking for.