2

I am implementing a taxonmy based navigation in SDL Web 8.5 with DXA 2.0. According to the documentation, I have created a category keyword with [Navigation] in its title.

enter image description here

I have published this Category and Keyword as well. In Unity.config, I have changed the mapping for INavigationProvider from Static to Dynamic as well.

 <type type="INavigationProvider" mapTo="DynamicNavigationProvider">
          <lifetime type="singleton" />
 </type>

I expect to see NavigationLinks model to be populated. However, it never happens. I put some code in try and catch to see what is the exception.

public static NavigationLinks GetDynamicNavigationLinks(this HtmlHelper helper,string requestUrlPath,Localization localization)
        {
            try
            {
                INavigationProvider navigationProvider = SiteConfiguration.NavigationProvider;
                var navigationLinks = navigationProvider.GetTopNavigationLinks(requestUrlPath, localization);
                return navigationLinks;
            }
            catch(Exception exception)
            {
                throw exception;
            }

        }

The exception is as follows:

    2018-07-20 09:47:30,826 [9] DEBUG - No value cached for key 'GetNavigationModel:17' in region 'Navigation_Dynamic'.
2018-07-20 09:47:48,988 [9] ERROR - DXA Model Service returned an unexpected response for URL 'http://webcmsnd.[domainName].org:8998/':
DXA Model Service returned an unexpected response from request 'http://webcmsnd.[domainName].org:8998/api/navigation/17' of . 
2018-07-20 09:47:49,337 [9] ERROR - DXA Model Service returned an unexpected response.
Sdl.Web.Common.DxaException: DXA Model Service returned an unexpected response. ---> Sdl.Web.ModelService.ModelServiceException: DXA Model Service returned an unexpected response from request 'http://webcmsnd.[domainName].org:8998/api/navigation/17' of . ---> System.ArgumentNullException: Value cannot be null.
Parameter name: value
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Sdl.Web.ModelService.ModelServiceClient.PerformRequest[T](IModelServiceRequest request)
   --- End of inner exception stack trace ---
   at Sdl.Web.ModelService.ModelServiceClient.PerformRequest[T](IModelServiceRequest request)
   at Sdl.Web.Tridion.ModelService.DefaultModelServiceProvider.GetSitemapItem(Localization localization)
   --- End of inner exception stack trace ---
   at Sdl.Web.Tridion.ModelService.DefaultModelServiceProvider.GetSitemapItem(Localization localization)
   at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.<>c__DisplayClass2_0.<GetNavigationModel>b__0()
   at Sdl.Web.Tridion.Caching.CacheProvider.GetOrAdd[T](String key, String region, Func`1 addFunction, IEnumerable`1 dependencies)
   at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.GetNavigationModel(Localization localization)
   at Sdl.Web.Tridion.Navigation.ModelServiceImpl.DynamicNavigationProvider.GetBreadcrumbNavigationLinks(String requestUrlPath, Localization localization)
   at Sdl.Web.Tridion.Navigation.DynamicNavigationProvider.GetBreadcrumbNavigationLinks(String requestUrlPath, Localization localization)
   at Sdl.Web.Mvc.Controllers.NavigationController.Navigation(EntityModel entity, String navType, Int32 containerSize)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
2018-07-20 09:53:35,466 [9] DEBUG - No value cached for key 'GetNavigationModel:17' in region 'Navigation_Dynamic'.
2018-07-20 09:53:52,372 [9] ERROR - DXA Model Service returned an unexpected response for URL 'http://webcmsnd.[domainName].org:8998/':
DXA Model Service returned an unexpected response from request 'http://webcmsnd.[domainName].org:8998/api/navigation/17' of . 

When I make the Get request to the Navigation API however, I get the data: Get -> http://webcmsnd.[domainName].org:8998/api/navigation/17

{
   "Id":"t25583",
   "Type":"TaxonomyNode",
   "Title":"Dynamic [Navigation]",
   "OriginalTitle":"Dynamic [Navigation]",
   "Visible":false,
   "Items":[
      {
         "$type":"TaxonomyNodeModelData",
         "Id":"t25583-k232401",
         "Type":"TaxonomyNode",
         "Title":"Home",
         "OriginalTitle":"000 Home",
         "Visible":false,
         "Items":[
            {
               "$type":"TaxonomyNodeModelData",
               "Id":"t25583-k232404",
               "Type":"TaxonomyNode",
               "Title":"Articles",
               "OriginalTitle":"010 Articles",
               "Visible":false,
               "Items":[

               ],
               "Key":"010 Articles",
               "HasChildNodes":false,
               "Description":"Articles",
               "IsAbstract":false,
               "ClassifiedItemsCount":0
            }
         ],
         "Key":"000 Home",
         "HasChildNodes":true,
         "Description":"Home",
         "IsAbstract":false,
         "ClassifiedItemsCount":0
      },
      {
         "$type":"TaxonomyNodeModelData",
         "Id":"t25583-k232402",
         "Type":"TaxonomyNode",
         "Title":"Resource",
         "OriginalTitle":"010 Resource",
         "Visible":false,
         "Items":[

         ],
         "Key":"010 Resource",
         "HasChildNodes":false,
         "Description":"Resource",
         "IsAbstract":false,
         "ClassifiedItemsCount":0
      },
      {
         "$type":"TaxonomyNodeModelData",
         "Id":"t25583-k232403",
         "Type":"TaxonomyNode",
         "Title":"News",
         "OriginalTitle":"020 News",
         "Visible":false,
         "Items":[

         ],
         "Key":"020 News",
         "HasChildNodes":false,
         "Description":"News",
         "IsAbstract":false,
         "ClassifiedItemsCount":0
      }
   ],
   "Key":"",
   "HasChildNodes":false,
   "Description":"",
   "IsAbstract":true,
   "ClassifiedItemsCount":0
}

I further investigated this issue and found out that the cause of error is ModelServiceClient.cs in PerformRequest method. For reasons that are unknown to me, the request times out on request.GetResponse(). The same request can be made on PostMan or browser and the JSON formatted data returns as expected.

enter image description here

Line 199 in ModelServiceClient.cs is where the timeout exception happens.

enter image description here

My questions are:

  1. Why the request times out on request.GetResponse()? (it is probably an infrastructure issue, what is that?)
  2. How can I customize the category keyword navigation to add customized fields and publishing them as JSON?
  • The cause of the exception is that the Model Service returned an unexpected response. If you set log level to DEBUG, you should be able to see the Model Service request and response. Furthermore, the Model Service log file might reveal the issue. – Rick Pannekoek Jul 20 '18 at 17:22
  • @RickPannekoek Log level is already set to DEBUG. The log that I have attached is the result of that. – Payam Jul 20 '18 at 17:25
  • I only see one ERROR line, though. I’m not asking to include the entire debug log, though. Just explaining how you can dive deeper yourself. – Rick Pannekoek Jul 20 '18 at 17:28
  • @RickPannekoek I added more to the log. However, I am more concerned that if I am missing a step in the process of getting this dynamic navigation data. Looking at the documentation, it seems that I have taken all the steps. – Payam Jul 20 '18 at 17:37
  • I doubt that the problem lies in missing a step. You should dive deeper to find the root cause of the exception. Unfortunately, debug logging reveals less than I expected. I think the Model Service request URL path is /api/navigation/17 – Rick Pannekoek Jul 20 '18 at 18:40
2

After a lot of digging, I made the following changes to the request object in ModelServiceCleint.cs

enter image description here

Lines 162 and 163 were added. This time the request didn't timeout and I got the response back. Obviously, this is not a solution, but just isolating the root cause. There must be a performance issue on the DXA service side.

  • Nice that you managed to demystify the issue and find a work-around. Please do report this isssue on GitHub. That is: unclear error handling (why doesn’t it say there was a timeout) and lack of ability to configure the timeout (?). – Rick Pannekoek Aug 2 '18 at 15:48
  • I hope you will continue your quest regarding the performance issue (maybe with help from SDL Customer Support)? Is your Taxonomy very large? – Rick Pannekoek Aug 2 '18 at 15:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.