Resolving incorrect configuration of UrlAgent


Description

Sitecore’s UrlAgent, which helps keep sites in a warmed-up state, may not work properly and fail to request the keepalive.aspx page with the error similar to the following:

ERROR Exception in UrlAgent (url: /sitecore/service/keepalive.aspx) 
Exception: System.Net.WebException 
Message: {ERROR MESSAGE}
Source: System 
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) 
   at System.Net.WebClient.DownloadData(Uri address) 
   at System.Net.WebClient.DownloadData(String address) 
   at Sitecore.Web.WebUtil.ExecuteWebPage(String url, NameValueCollection headers) 
   at Sitecore.Tasks.UrlAgent.Run() 

Based on the exception message you see in log files, choose the appropriate solution.

Scenario 1

Error message:

The following message may appear when the anonymous access to the /Website/sitecore/service folder is not allowed:

Message: The remote server returned an error: (401) Unauthorized.

Solution:

Enable anonymous access to the /Website/sitecore/service folder by applying the steps described in the following article:
http://technet.microsoft.com/en-us/library/cc731244(v=ws.10).aspx

Alternatively, move the /Website/sitecore/service/keepalive.aspx file to a separate location and appropriately modify the value of the url parameter of the keep-alive agent configuration in web.config:

<agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:15:00">
  <param desc="url">/sitecore/service/keepalive.aspx</param>
<LogActivity>true</LogActivity>
</agent>

Scenario 2

Error message:

The following message may appear when the system cannot reach the DNS server to resolve the host name, or if the specified host name is not correct.

Message: The remote name could not be resolved: 'hostname'

Solution:

Scenario 3

Error message:

The following message may appear when the /Website/sitecore/service/keepalive.aspx page specified in the UrlAgent configuration is absent on the server.

In Sitecore versions prior to 6.6.0 Update-4 this error may also happen if the Sitecore website is not configured to handle requests that use "localhost" as a hostname:

Message: The remote server returned an error: (404) Not Found.

Solution:

Verify that the /Website/sitecore/service/keepalive.aspx page exists. If it does not exist, please copy it from the stock Sitecore installation.

If you use Sitecore version prior to 6.6.0 Update-4, please see the following known issue as well:
KB0714882

Scenario 4

Error message:

The following message may appear when the SSL connection is required for accessing the /Website/sitecore/service folder:

Message: The remote server returned an error: (403) Forbidden.

Solution:

In the UrlAgent configuration specify the absolute URL using the HTTPS protocol as below:

<agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:15:00">
  <param desc="url">https://<hostname>/sitecore/service/keepalive.aspx</param>
  <LogActivity>true</LogActivity>
</agent>