{"id":8516,"date":"2020-01-07T13:18:47","date_gmt":"2020-01-07T21:18:47","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=8516"},"modified":"2020-01-07T13:18:47","modified_gmt":"2020-01-07T21:18:47","slug":"check-web-server-sanity-check","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/service-protector\/check-web-server-sanity-check\/","title":{"rendered":"Q&#038;A: How do I Test the &#8220;Check Web Server&#8221; Sanity Check?"},"content":{"rendered":"<div align=\"center\"><img decoding=\"async\" src=\"\/blog\/images\/qa-test-web-server.png\" title=\"Q&#038;A - Test Web Server\" alt=\"Q&#038;A - Test Web Server\" border=\"0\" ><\/div>\n<div class=\"blog-qa-question-box\">\n<img decoding=\"async\" src=\"\/images\/quotes-transparent-21x21.png\">&nbsp;&nbsp;I&#8217;ve already started the trial of the <a href=\"\/products\/ServiceProtector\">Service Protector<\/a> and I&#8217;m comfortable with the way it is working. I manually stopped my web service and Service Protector started it up right away.<\/p>\n<p>I&#8217;m specifically interested in detecting some nasty 502 errors and downloaded the <a href=\"\/products\/AlwaysUp\/Plugins\/#CheckWebSiteForErrors\">check website BAT file<\/a>. <\/p>\n<p>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.<\/p>\n<p align=\"right\">&mdash; Greg<\/p>\n<\/div>\n<p>Hi Greg, thanks for trying Service Protector.<\/p>\n<p>After discussing with our team, here are three ways you can test:<\/p>\n<h2 class=\"blog-caption-numbered\">1. Specify a non-working URL<\/h2>\n<p>To make the sanity check work, you had to specify your server&#8217;s URL in the batch file (in the <b>SET url<\/b> line).<\/p>\n<p>For example:<\/p>\n<pre>\r\n      <b>SET url=http:\/\/localhost:8080<\/b>\r\n<\/pre>\n<p>To confirm that your service will be promptly restarted when the sanity check fails, simply specify a bogus URL in the batch file.<\/p>\n<p>An invalid URL will cause the URL ping to fail and signal Service Protector to restart your Windows Service &mdash; every time the sanity check runs.<\/p>\n<p>To perform this test:<\/p>\n<ol>\n<li>\n<p>Open the batch file in your favorite text editor<\/p>\n<\/li>\n<li>\n<p>Update the <b>SET url<\/b> line with a URL that does not point to an actual site<\/p>\n<\/li>\n<li>\n<p>Save the batch file<\/p>\n<\/li>\n<li>\n<p>Launch Service Protector<\/p>\n<\/li>\n<li>\n<p>Highlight your web server service and select <b>Application &gt; Start Protector<\/b><\/p>\n<\/li>\n<li>\n<p>Wait for the sanity check to be run (as per the frequency you provided when you setup the sanity check)<\/p>\n<\/li>\n<li>\n<p>Validate that your service is stopped and restarted, as expected<\/b><\/p>\n<\/li>\n<\/ol>\n<h2 class=\"blog-caption-numbered\">2. Update your web application to return a 502<\/h2>\n<p>The previous test applies to all failures, not only 502 errors.<\/p>\n<p>If you have control of your web site code &mdash; in <a href=\"https:\/\/laravel.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Laravel<\/a>, <a href=\"https:\/\/www.djangoproject.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Django<\/a>, <a href=\"https:\/\/dotnet.microsoft.com\/apps\/aspnet\" target=\"_blank\" rel=\"noopener noreferrer\">ASP.NET<\/a> or another dynamic framework &mdash; you can create a URL endpoint that simply returns 502.<\/p>\n<p>Put that URL that into the check website batch file (in the <b>SET url<\/b> line) and your service should be restarted whenever Service Protector runs the sanity check.<\/p>\n<h2 class=\"blog-caption-numbered\">3. Use the free  webhook service<\/h2>\n<p>If you don&#8217;t want to mess with your web site, we recommend use the <a href=\"https:\/\/webhook.site\/\" target=\"_blank\" rel=\"noopener noreferrer\">free webhook service<\/a> 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.<\/p>\n<p>To create the endpoint:<\/p>\n<ol>\n<li>\n<p>Open this page in your browser: <a href=\"https:\/\/webhook.site\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/webhook.site\/<\/a><\/p>\n<p>A unique URL will be created automatically for you:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-webhook-url.png\" class=\"zoomPopup\" title=\"Create a Webhook URL\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-webhook-url.png\" title=\"Create a Webhook URL (click to enlarge)\" alt=\"Create a Webhook URL\" border=\"0\" width=\"500\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>This URL is immediately usable, but it will return HTTP Status code 200 by default. Click the <b>Edit<\/b> button and change the <b>Default status code<\/b> to 502. You might as well put in some response text, to explicitly signal what the URL does too:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/edit-webhook-status-code.png\" class=\"zoomPopup\" title=\"Set the Webhook default status code to 502\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/edit-webhook-status-code.png\" title=\"Set the Webhook default status code to 502 (click to enlarge)\" alt=\"Set the Webhook default status code to 502\" border=\"0\" width=\"500\" \/><\/a><\/div>\n<\/li>\n<\/ol>\n<p>Visit the URL to ensure that it is responding as expected:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/webhook-502-response.png\" class=\"zoomPopup\" title=\"Check that the Webhook URL returns 502\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/webhook-502-response.png\" title=\"Check that the Webhook URL returns 502 (click to enlarge)\" alt=\"Check that the Webhook URL returns 502\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Note that the URL won&#8217;t be available forever. From the <a href=\"https:\/\/webhook.site\/terms\" target=\"_blank\" rel=\"noopener noreferrer\">Webhook.site Terms of use<\/a>:<\/p>\n<div class=\"blog-qa-question-box\">\n<img decoding=\"async\" src=\"\/images\/quotes-transparent-21x21.png\">&nbsp;&nbsp;For non-Premium URLs, data may be automatically deleted after a maximum of 7 days.\n<\/div>\n<p>So you&#8217;ll have to purchase a premium offering if you want the URL to persist.<\/p>\n<p style=\"margin-top:30px\">\nHappy testing!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/version-16-advanced-failure-detection\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"AlwaysUp 16 Handles Common Application Failures &mdash; So You Don&#039;t Have To\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/whats-new-3.webp\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">AlwaysUp 16 Handles Common Application Failures &mdash; So You Don&#039;t Have To<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-batch-file-hangs\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: How Do I Force AlwaysUp To Restart My Batch File When It Hangs?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/batch-file-150x150-1.webp\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: How Do I Force AlwaysUp To Restart My Batch File When It Hangs?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-idle-application\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q &amp; A: Can AlwaysUp Kill &amp; Restart my Idle Application?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/qa-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q &amp; A: Can AlwaysUp Kill &amp; Restart my Idle Application?<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;I&#8217;ve already started the trial of the Service Protector and I&#8217;m comfortable with the way it is working. I manually stopped my web service and Service Protector started it up right away. I&#8217;m specifically interested in detecting some nasty 502 &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/service-protector\/check-web-server-sanity-check\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":8522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[20,54,138,147,203],"class_list":["post-8516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-service-protector","tag-502-http-status-code","tag-check-website-sanity-check","tag-sanity-check","tag-service-protector-tag","tag-webhook-site"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/8516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=8516"}],"version-history":[{"count":0,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/8516\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/8522"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=8516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=8516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=8516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}