ERROR Failed to enroll a contact in the engagement plan.
Exception: System.Net.WebException
Message: The remote name could not be resolved: 'default-cd-cluster'
Source: System
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at Sitecore.Modules.EmailCampaign.Core.Gateways.DefaultAnalyticsGateway.EnrollOrUpdateContact(Guid contactId, Guid planId, Guid automationStateId, EcmCustomValues customValues, String[] validStates)
at Sitecore.Modules.EmailCampaign.Core.Analytics.AutomationStatesManager.EnrollOrUpdateContact(Guid contactId, Guid planId, String stateName, EcmCustomValues customValues, String[] validStates)
at Sitecore.Modules.EmailCampaign.Core.Dispatch.DispatchManager.EnrollOrUpdateContact(Guid contactId, DispatchQueueItem dispatchQueueItem, Guid planId, String stateName, EcmCustomValues customValues)
at Sitecore.Modules.EmailCampaign.Core.Dispatch.DispatchTask.OnSendToNextRecipient()
After search this error message I found two articles (first, second) that say the same: you should change Analytics.ClusterName setting. And this solution really helps. This setting is located in Sitecore.Analytics.Tracking.config file and EXM uses it to access to /sitecore/AutomationStates.ashx handler to change contact state in engagement plan.
But, doesn't sound strange? That you should to configure something to start work with Sitecore single instance. How about installation CM/CD/Analytics on one server? Or how about development and testing environments? I know that there are a lot of places where Sitecore as web application requires host name, but everywhere it works automatically. You shouldn't configure something additionally. That's why I decided to customize Sitecore to use 'default-cd-cluster' as key that will be replaced in EXM with current host name. And it was quite easy:
public class CustomAnalyticsGateway : DefaultAnalyticsGateway { public override ContactLockingStatus TryGetContactForUpdate(ID contactId, LeaseOwner leaseOwner, System.TimeSpan leaseDuration, System.TimeSpan timeout, out Sitecore.Analytics.Tracking.Contact contact, out string webClusterName) { var r = base.TryGetContactForUpdate(contactId, leaseOwner, leaseDuration, timeout, out contact, out webClusterName); if (webClusterName!= null && webClusterName.Contains("default-cd-cluster")) { webClusterName = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName(); } return r; } }
If webClsterName contains 'default-cd-cluster' we change it with current sitename(it also will work if we will replace it with null due to Sitecore EXM later fill it with another value if it is null). And you should let EXM know to use this gateway in your configuration:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <gatewayFactory> <analyticsGateway type="YourSolution.CustomAnalyticsGateway, YourSolution"/> </gatewayFactory> </sitecore> </configuration>
With this custom class and configuration Email Experience Manager started to work on all machines. And you should not change 'default-cd-cluster' with host name in all your solutions. But don't forget to change this setting when going to live environment.