4

So after a clean install of Sitecore, I've been trying to get an app working with xConnect, but when I'm running that I'm getting the following exception in my code:

No connection could be made because the target machine actively refused it

The code I'm using:

var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
var connectionString = WebConfigurationManager.AppSettings["xConnectConnectionString"];
var collectionClientUrl = WebConfigurationManager.AppSettings["xConnectCollectionClientUrl"];
var searchClientUrl = WebConfigurationManager.AppSettings["xConnectSearchClientUrl"];
var configurationClientUrl = WebConfigurationManager.AppSettings["xConnectConfigurationClientUrl"];
await XConnect.Initialize(connectionString, collectionClientUrl, searchClientUrl, configurationClientUrl);

The values in the appsettings are:

<add key="xConnectConnectionString" value="StoreName=My;StoreLocation=LocalMachine;FindType=FindByThumbprint;FindValue=D277A26033FA68500804EEB7E108754A3A4968FD;AllowInvalidClientCertificates=true" />
<add key="xConnectCollectionClientUrl" value="https://blank.902.local.xconnect/odata" />
<add key="xConnectSearchClientUrl" value="https://blank.902.local.xconnect/odata" />
<add key="xConnectConfigurationClientUrl" value="https://blank.902.local.xconnect/configuration" />

The Thumbprint you see in the xConnectConnectionString is the thumbprint for the xConnect certificate (for clarity: not client certificate)

XConnect is a custom class, XConnect.Initialize does this (pretty much copy/paste from the documentation):

public static async Task Initialize(string connectionString, string collectionClientUrl, string searchClientUrl, string configurationClientUrl)
{
    var options = CertificateWebRequestHandlerModifierOptions.Parse(connectionString);

    var certificateModifier = new CertificateWebRequestHandlerModifier(options);

    var clientModifiers = new List<IHttpClientModifier>();
    var timeoutClientModifier = new TimeoutHttpClientModifier(new TimeSpan(0, 0, 20));
    clientModifiers.Add(timeoutClientModifier);

    var collectionClient = new CollectionWebApiClient(new Uri(collectionClientUrl), clientModifiers, new[] { certificateModifier });
    var searchClient = new SearchWebApiClient(new Uri(searchClientUrl), clientModifiers, new[] { certificateModifier });
    var configurationClient = new ConfigurationWebApiClient(new Uri(configurationClientUrl), clientModifiers, new[] { certificateModifier });

    Cfg = new XConnectClientConfiguration(new XdbRuntimeModel(CollectionModel.Model), collectionClient, searchClient, configurationClient);

    try
    {
        await Cfg.InitializeAsync();
    }
    catch (XdbModelConflictException ce)
    {
        //I am not sure what to do with exception now
    }
    catch (Exception ex)
    {
        //I am not sure what to do with exception now
        throw;
    }
}

I've tried uploading a list in List Manager as well, which seems to have the same type of issue. After uploading a list with 2 contacts I do see the list and it seems to have contacts assigned to it, but the contacts do not show in Experience Profile.

Test list with contacts

If I go into the list, I see the following error message:

Contacts are being indexed message

If I check my Sitecore log files, I get the following message there:

ManagedPoolThread #2 10:11:35 ERROR Exception Exception: System.Reflection.TargetInvocationException Message: Exception has been thrown by the target of an invocation. Source: mscorlib at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj) at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args) at (Object , Object ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) at Sitecore.Jobs.Job.DoExecute() at Sitecore.Jobs.Job.ThreadEntry(Object state)

Nested Exception

Exception: Sitecore.XConnect.XdbSearchUnavailableException Message: An error occurred while sending the request. Source: Sitecore.XConnect.Client at Sitecore.XConnect.Client.WebApi.SearchWebApiClient.d__91.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Client.Operations.SearchOperationInvoker.<Execute>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Sitecore.XConnect.Search.SearchHelpers.<ExecuteSearch>d__61.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Search.SearchDefinition1.<Execute>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Search.AsyncSearchHitEnumerator1.d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Search.AsyncEntityQueryProvider.d__81.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Search.AsyncEntityQueryProvider.<ExecuteAsync>d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.ListManagement.XConnect.ContactsOperationIndexingState.IsFinished(String syncToken) at Sitecore.ListManagement.Operations.UpdateListOperationsAgent.CheckIndexing(ListOperation listOperation)

Nested Exception

Exception: Sitecore.Xdb.Common.Web.ConnectionTimeoutException Message: A task was canceled. Source: Sitecore.Xdb.Common.Web at Sitecore.Xdb.Common.Web.CommonWebApiClient1.<ExecuteAsync>d__37.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Client.WebApi.SearchWebApiClient.<Search>d__91.MoveNext()

Nested Exception

Exception: System.Threading.Tasks.TaskCanceledException Message: A task was canceled. Source: mscorlib at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.Xdb.Common.Web.CommonWebApiClient`1.d__37.MoveNext()

And if I check the log file for the IndexWorker, I get a whole bunch of this:

2018-10-19 09:44:12.229 +01:00 [Error] An error occured. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8989 at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult) at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.Xdb.Collection.Search.Solr.SolrClient.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.Xdb.Collection.Search.Solr.SolrRebuildStatusStorage.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Search.Indexer.IndexerHost.d__28.MoveNext()

However, in the ConnectionStrings.config I've got the following:

<add name="solrCore" connectionString="https://localhost:8989/solr/blank.902.local_xdb" />

Not entirely sure where 127.0.0.1 comes from rather than localhost - but even then https://127.0.0.1:8989 is accessible and redirects to my SOLR - it's just http that doesn't...
Lastly all environments (xConnect, Sitecore and SOLR) all are running in HTTPS with a valid (self-signed) certificate.

edit

Not sure if this is relevant but in my xConnect AppSettings configuration I do have the following set:

<add key="AllowInvalidClientCertificates" value="true" />

And I commented out the validateCertificateThumbprint setting.

Edit 2

So the first part of the question is now answered due to be being a numpty. I was having issues with the certificates initially, so I was using Fiddler in combination with my custom application so I could get the error code back. To enable Fiddler I added the following to the web.config:

<system.net>
    <defaultProxy>
      <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
    </defaultProxy>
</system.net>

Removing that from web.config stops the error from being thrown in my custom app trying to connect with xConnect. Still had issues though as Solr and the Index Worker can't communicate.

HttpRequestException: Response status code does not indicate success: 503 ({metadata={error-class=org.apache.solr.common.SolrException,root-error-class=org.apache.solr.common.SolrException},msg=SolrCore is loading,code=503}).

Now when I open SOLR I also get the following:

Solr error

Error is all about:

SolrException: Error opening new searcher

Reading the inner exception there::

Caused by: org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine: C:\Solr-6.6.0\server\solr\blank.902.local_xdb_rebuild\data\index\write.lock

I then tried to follow the rebuilding steps found on the doc site but messed up massively, corrupted the various cores that were working so had to reinstall for the umpteenth time.

While I did this reinstall, I noticed something strange on my XConnect Client cert in the MS Management Console, although did not screengrab it. I ended up generating my own SSL cert for XConnect Client (via PowerShell). Added this to Trusted Root Certification Authorities after importing and ran into an issue with security - added IIS user to the permissions for the cert and... Still nothing.

This is now the exception in the xConnect log:

2018-10-23 14:30:27.189 +01:00 [Error] Sitecore.XConnect.Operations.XdbSearchOperation`1[Sitecore.XConnect.Contact]: System.TimeoutException: A wait for data to be indexed has been timed out. 2018-10-23 14:30:27.189 +01:00 [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception System.TimeoutException: A wait for data to be indexed has been timed out.

In the IndexWorker logfile I'm getting the same I was getting at the start of this:

2018-10-23 13:17:38.522 +01:00 [Error] An error occured. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8989

Although I'm now also getting the following:

2018-10-23 13:17:42.168 +01:00 [Error] An error occured. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine

I'm accessing the website on https, xConnect is on https, SOLR runs under https - but looking at the earlier error it seems like it's trying to access SOLR on http://127.0.0.1:8989 instead of https...

  • Salutations! Could you tell me where the first code example is from? I don't recognize XConnect.Initialize. There are instructions here on how to connect to xConnect from a non-Sitecore context (I assume that is what you are referring to when you say app): doc.sitecore.net/developers/xp/xconnect/xconnect-client-api/… – mhwelander Oct 19 '18 at 10:13
  • @mhwelander I've updated the question. XConnect.Initialize pretty much is a copy/paste from the link you sent. It doesn't necessarily seem related to xConnect only though, to me it looks like a problem with the IndexWorker – Trayek Oct 19 '18 at 10:21
  • 1
    I am certain you have checked this multiple times, but want to check again. The Client Certificate for xConnect are installed on both the xConnect Server as well as the server you are trying to connect from, and the Subject Alternative Name matches the domain name of the xConnect server you are connecting to, and the thumbprint matches on both servers as well as in all configs? – Pete Navarra Oct 20 '18 at 0:57
  • @PeteNavarra working locally, so client cert is on xConnect server as well as server I'm connecting from. Subject Alternative Name for xConnect Client cert is 'blank.902.local.xconnect_client' (SIF auto-adds {prefix}_client, haven't changed anything here). I can reach xConnect on blank.902.local.xconnect (which matches Subject Alternative Name for xConnect cert). Oh and thumbprint matches: I've commented out the validateCertificateThumbprint in xConnect AppSettings.config, and set AllowInvalidClientCertificates to true. In the website Connectionstrings the thumbprint matches the xConnect cert – Trayek Oct 22 '18 at 8:11
  • Your windows firewall isn't turned on right? i'm assuming no, or else Solr wouldn't even work. Really odd. TLS version maybe? Is 1.2 enabled in Windows? – Pete Navarra Oct 22 '18 at 23:33

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.