I’m specifically interested in detecting some nasty 502 errors and downloaded the check website BAT file.
Any suggestions on how to simulate or force a 502? My test environments rarely crash (of course) and I need to gain a little bit of confidence before applying to one of our big customers.
Hi Greg, thanks for trying Service Protector.
After discussing with our team, here are three ways you can test:
1. Specify a non-working URL
To make the sanity check work, you had to specify your server’s URL in the batch file (in the SET url line).
To confirm that your service will be promptly restarted when the sanity check fails, simply specify a bogus URL in the batch file.
An invalid URL will cause the URL ping to fail and signal Service Protector to restart your Windows Service — every time the sanity check runs.
To perform this test:
Open the batch file in your favorite text editor
Update the SET url line with a URL that does not point to an actual site
Save the batch file
Launch Service Protector
Highlight your web server service and select Application > Start Protector
Wait for the sanity check to be run (as per the frequency you provided when you setup the sanity check)
Validate that your service is stopped and restarted, as expected
2. Update your web application to return a 502
The previous test applies to all failures, not only 502 errors.
Put that URL that into the check website batch file (in the SET url line) and your service should be restarted whenever Service Protector runs the sanity check.
3. Use the free webhook service
If you don’t want to mess with your web site, we recommend use the free webhook service to create a URL that always returns a 502. If you place that URL in your batch file, your service should be restarted every time the sanity check is run.
To create the endpoint:
Open this page in your browser: https://webhook.site/
A unique URL will be created automatically for you:
This URL is immediately usable, but it will return HTTP Status code 200 by default. Click the Edit button and change the Default status code to 502. You might as well put in some response text, to explicitly signal what the URL does too:
Visit the URL to ensure that it is responding as expected:
So you’ll have to purchase a premium offering if you want the URL to persist.