Surendra Sharma

Surendra Sharma

Search This Blog

Friday, March 24, 2017

Exception in UrlAgent url: /sitecore/service/keepalive.aspx

We notice below error in our project log files on CD server as 
 
ManagedPoolThread #15 00:23:21 INFO  Job started: Sitecore.Tasks.UrlAgent
ManagedPoolThread #15 00:23:21 INFO  Scheduling.UrlAgent started. Url: http://www.sitecorelessons.com/sitecore/service/keepalive.aspx
ManagedPoolThread #15 00:23:21 ERROR Exception in UrlAgent (url: /sitecore/service/keepalive.aspx)
Exception: System.Net.WebException
Message: The remote server returned an error: (401) Unauthorized.
Source: System
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)
   at Sitecore.Web.WebUtil.ExecuteWebPage(String url, NameValueCollection headers)
   at Sitecore.Tasks.UrlAgent.Run()
ManagedPoolThread #15 00:23:21 INFO  Job ended: Sitecore.Tasks.UrlAgent (units processed: )

What’s the root cause and how to fix this error?

Solution:

Problem was that Anonymous access permission was denied on server for Sitecore folder.

It’s a good practice to remove access permissions from Sitecore folder on CD server.

However to fix this issue either we have to provide access permission to Service folder or keep its files on some other location and then change config files entries according to that new path.

We can provide access permission to service folder as

  • Open IIS
  • Navigate to Service folder of your website and open Authentication as
 
Folder Authentication
Folder Authentication

  • Select Anonymous Authentication and Enable its status as
 
Enable Anonymous Authentication
Enable Anonymous Authentication

That's it.

We didn’t find any new error in log files after allowing permission to Service folder.

After fixing this, we are now receiving proper log as

ManagedPoolThread #6 02:12:23 INFO  Job started: Sitecore.Tasks.UrlAgent
ManagedPoolThread #6 02:12:23 INFO  Scheduling.UrlAgent started. Url: http://www.sitecorelessons.com/sitecore/service/keepalive.aspx
ManagedPoolThread #6 02:12:23 INFO  Scheduling.UrlAgent done (received: 561 bytes)
ManagedPoolThread #6 02:12:23 INFO  Job ended: Sitecore.Tasks.UrlAgent (units processed: )

I hope you like this Sitecore tip. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this script if it’s useful for you.

Thursday, March 23, 2017

How to expire Sitecore session forcefully



In one of our project, I have to forcefully expire the Sitecore session so that it flush the data to MongoDB.

For this either you can restart IIS or start-stop your website. But this action require you to login into the system. But what if you are accessing Sitecore remotely or over the internet.

So I write this script which expire the session and clear the Sitecore analytics related cookies.

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <%
            Context.Session.Abandon();
            HttpContext.Current.Request.Cookies.Remove("ASP.NET_SessionId");
            Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", string.Empty));
            HttpContext.Current.Request.Cookies.Remove("SC_ANALYTICS_SESSION_COOKIE");
            Response.Cookies.Add(new HttpCookie("SC_ANALYTICS_SESSION_COOKIE", string.Empty));
            HttpContext.Current.Request.Cookies.Remove("SC_ANALYTICS_GLOBAL_COOKIE");
            Response.Cookies.Add(new HttpCookie("SC_ANALYTICS_GLOBAL_COOKIE", string.Empty));
        %>
    </form>
</body>
</html>

I called this script as "ForceSessionEnd.aspx" and keep it in "Website" folder.

Access this script over the browser as "http://yourinstancename/forcesessionend.aspx".

After running this page, you will get latest data on mongo database.

Feel free to add more cookies as per your need.

I hope you like this Sitecore script. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)
 
Please leave your comments or share this script if it’s useful for you.

Wednesday, March 22, 2017

Failed to perform MaxMind lookup

In our CD server we are recelving lots of log errors related with MaxMind lookups as
 
ManagedPoolThread #17 00:37:24 ERROR Failed to perform MaxMind lookup
ManagedPoolThread #17 00:37:24 ERROR Failed to perform GeoIp lookup for 192.168.0.74
Exception: Sitecore.Analytics.Lookups.CannotParseResponseException
Message: Unexpected format. Cannot parse the MaxMind response for IP address: 192.168.0.74
Source: Sitecore.Analytics
   at Sitecore.Analytics.Lookups.MaxMindProvider.GetInformationByIp(String ip)
   at Sitecore.Analytics.Lookups.GeoIpManager.GetDataFromLookupProvider(GeoIpHandle geoIpHandle)

We want to stop this MaxMind lookup functionality as we are not using this in our project.

Solution:

We can disable MaxMind lookup operation by editing “Sitecore.Analytics.config” file and by making “false” entry to “Analytics.PerformLookup” key as

<!--  ANALYTICS PERFORM LOOKUP
      Determines if this server performs the lookups (DNS and URLs). Only one server should be responsible for performning the lookup.
      Default: true
-->
<setting name="Analytics.PerformLookup" value="false" />

After this change we didn’t find any MaxMind related errors in Sitecore log file.

I hope you like this Sitecore tip. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)
 
Please leave your comments or share this tip if it’s useful for you.