Gravatar for christopher.everitt@abc.virginia.gov

Question by Chris, Jan 15, 2019 10:23 AM

417 Expectation Failed When Using ICoveoSearchContext

We've introduced code that uses our coveo index to aquire sitecore items that belong to a specific bucket. Previously these items were aquired by traversing the bucket. In both the old and the new implementation, we use the Url of the request to derive what the Sitecore item name is.

We introduced a custom HttpRequestProcessor into our HttpRequestProcessing pipeline. The code basically does this:

// Use the coveo index
using (var context = ContentSearchManager.GetIndex(CurrentCoveoIndex).CreateSearchContext())
{
    ICoveoSearchContext coveoContext = context as ICoveoSearchContext;
    // Get the item from the index based on the url
    var results = context.GetQueryable<T>().Where(i => i.Name.Equals(nameDerivedFromUrl));
    // Set the item for this request to be the relevent item from the results of the search
    Sitecore.Context.Item(results[0]);
}

We get this error when visiting a url that would cause our new HttpProcessor to fire:

Exception: Coveo.Framework.Utils.Rest.HttpClientException
Message: Failed to obtain resource located at 'https://my.sitecore.site/coveo/rest?indexName=mypubwebindex'.
[BEGIN RESPONSE BODY]<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>417 Expectation Failed</title>
</head><body>
<h1>Expectation Failed</h1>
<p>The expectation given in the Expect request-header
field could not be met by this server.
The client sent<pre>
    Expect: 100-continue
</pre>
</p><p>Only the 100-continue expectation is supported.</p>
</body></html>
[END RESPONSE BODY]
Source: Coveo.Framework
   at Coveo.Framework.Utils.Rest.HttpClient.HandleResponseException(WebException pException, String pUrl, Int64 pCallId)
   at Coveo.Framework.Utils.Rest.HttpClient.ExecuteRequest(String pUrl, Func2 p_CreateRequest, Int64 p_CallId)
   at Coveo.Framework.Utils.Rest.HttpClient.Post(String p_Url, String p_Body)
   at Coveo.SearchServiceProvider.Rest.ClientSessionWrapper.ExecuteQuery(QueryParams p_QueryParams)
   at Coveo.SearchProvider.LinqToCoveoIndex1.ExecuteQuery[TElement](QueryParams pQuery, IEnumerable1 p_QueriedTypes)
   at Coveo.SearchProvider.LinqToCoveoIndex1.FindElements[TElement](CoveoCompositeQuery pQuery)
   at Sitecore.ContentSearch.Linq.Parsing.GenericQueryable2.GetEnumerator()
   at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
   at My.Sitecore.Solution.Pipelines.HttpRequest.GetBucketItemProcessor.GetItem[T](String itemPath, IProviderSearchContext context)
   at My.Sitecore.Solution.Pipelines.HttpRequest.GetBucketItemProcessor.DoIndexLookup(String itemPath, HttpRequestArgs args)
   at My.Sitecore.Solution.Pipelines.HttpRequest.GetBucketItemProcessor.<>cDisplayClass00.<Process>b0()
   at My.Sitecore.Solution.Caching.CacheManager.AddIfNotExists[T](String key, Func`1 addMethod)
   at My.Sitecore.Solution.Pipelines.HttpRequest.GetBucketItemProcessor.Process(HttpRequestArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Nexus.Web.HttpModule.’ (Object  , EventArgs  )
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I am able to GET and POST to https://my.sitecore.site/coveo/rest?indexName=mypubweb_index from my CD and receive good json from it, which makes me think the problem is elsewhere.

I have checked the coveo configuration:

coveo/restEndpointConfiguration/searchApiUri = http://my.sitecore.cm:8083/

coveo/restEndpointConfiguration/restEndpointPath = /coveo/rest

coveo/defaultIndexConfiguration/serverUrl = http://my.sitecore.cm/

For this environment the CES instance and my Search API are on my cm. So the config looks correct to me.

In my local environment, where the CM, CD, CES, and SearchApi are on the same machine I do not get the error. I get the error when I deploy this to a staging environment. In the staging environment the CM, CES, and SearchApi are on the same machine, and the CD on a different one.

Can you help me understand why this rest call (from the stacktrace) is going to https://my.sitecore.site/coveo/rest and not https://my.sitecore.cm/coveo/rest? I expected the configuration to cause the call to go to https://my.sitecore.cm/coveo/rest.

The diagnostic page in sitecore is also all green, the versions are:

Current Coveo for Sitecore version: 4.1.224.6

Current Sitecore version: 8.1.160519

Could you suggest some areas I might look to focus troubleshooting?

0 Reply
Ask a question