Hi, basically you need to handle exceptions when you are using Find and have different "friendly" results based on what the exception was.
Jonas has listed the Episerver Find exceptions in his blog post.
From end users point of view (user using your website), the fiendly error in all cases should be something like "Ooops, our search is not working." but from developers oint of view, the correct kind of log message about the reason why it failed is important.
BTW, HTTP status 401 is not time out but unauthorized.
Thank you Antti,
The biggest problem I'm running into is that my queries are still reaching out to Find despite the fact that the query is unauthorized. Therefor I am getting timeouts.
I'm trying to find a way to determine if the service is down or 401 before the query starts running and times out. That way I can throw a freindly message to the users within seconds intead of the minute or two it is taking me now.
Any idea on how I can run a quick test for this in the code before the query?
Hi, well I would drop the idea to first "ping" is the service alive and then take actions based on that.
I would suggest to use the 'defaultRequestTimeout' attribute on the episerver.find section in your web.config, in that attribute you can configure the default request timeout in milliseconds (the underlying HttpWebrequest uses default value of 100000ms (100 seconds) for the timeout).
<episerver.find serviceUrl="your-servuice-url-here" defaultIndex="your-index-name-here" defaultRequestTimeout="5000" />
The above setting sets the timeout to 5 seconds.
That seems to be a way to do it. Then I add a friendly message in the catch statement.
Thank you
My developer index timed out and this presented a great oppertunity for me to pop out friendly errors instead of a 401 in case we run into a network glitch in production
I'm trying to find a way to determine of the index invalid or unreachable (we are using on-prem and there is a chance we can't access the index) so that I can present a friendly error instead of a system 401 error.
The example code has a function to determine of the search in configured
This works great, but it doesn't account for if the service is running or a 401. Is there anything I can do to check for this? The only thing I can see is the settings is the query settings times out. For now I can play with that, but I'm certain there is a more graceful way to handle this.
Thanks!