It's not a normal behavior.
If you look at the error message, you can see that problem is related to:
System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
It meant that when any block tries to send request to Sitecore via SitecoreConnectionManager
, and
SitecoreConnectionManager
processes request via SitecoreConnectionManager.ProcessRequest
and couldn't create Uri:
SitecoreConnectionPolicy policy = commerceContext.GetPolicy<SitecoreConnectionPolicy>();
Uri address = new Uri(string.Format("https://{0}", (object) policy.Host));
From the first look it must works correctly, but...not...
Why do you see this error?
Commerce Engine OOTB has AdventureWorks
, Habitat
, any your custom environment(s) and ... Global environment
Engine tries to send request and get any item from Sitecore, but commerceContext
has Environment
property which is set to GlobalEnvironment
.
If you will open Global.json
file you will see that SitecoreConnectionPolicy
is missing for GlobalEnvironment
and for sure policy.Host
is equal null.
How to fix it?
You need to copy and paste configuration below to Global.json
file to Policies
list:
{
"$type": "Sitecore.Commerce.Plugin.Management.SitecoreConnectionPolicy, Sitecore.Commerce.Plugin.Management",
"Host": "{hostname.com}",
"SitecoreDatabase": "master",
"UserName": "admin",
"Domain": "sitecore",
"Password": "b",
"ConnectionLeaseTimeout": 60000,
"AuthRequestUrl": "sitecore/api/ssc/auth/login",
"Protocol": "https"
}
You need to change Host, UserName, Password base on your configuration.
Also you can find your existing configuration in PlugIn.Content.PolicySet-1.0.0.json
file and copy it to Global.json
file.
After that you need to Bootstrap engine and restart apppool or iis.
This fix I checked on Sitecore Commerce 9 Update-1.
In Sitecore Commerce 9 Update-2 was added additional check:
SitecoreConnectionPolicy policy = commerceContext.GetPolicy<SitecoreConnectionPolicy>();
if (string.IsNullOrEmpty(policy?.Host))
{
commerceContext.Logger.LogError(string.Format("SitecoreConnectionManager: SitecoreConnectionPolicy for {0} is missing the host configuration", (object) commerceContext.Environment.Name), Array.Empty<object>());
return (HttpResponseMessage) null;
}
Uri address = new Uri(string.Format("https://{0}", (object) policy.Host));
Which is more informative