I'm using the DD4T function FindAndStoreBinary together with BinaryDistributionModule to intercept calls for image files and retrieve them from the broker DB and physical location on the server. The problem I am encountering is that it only loads half of the images on the page. Also which images it loads seems to be random. In total the page only contains 8 images.

From the dd4t logs I pulled this error:

    WARN  2022-09-15 17:08:38,569  2390ms DefaultLogger          TryFindBinary      - Caught unexpected exception while retrieving binary with url /devportal/nl/Media/apis-consent_tcm112-158431.png (requested url: /devportal/nl/Media/apis-consent_tcm112-158431.png. Error message: Unauthorized Request -- Please check your configuration settings to make sure your authentication details are correct.
   at Sdl.Web.Delivery.Service.AbstractODataService.HandleHttpResponseCode(Exception e, Int32 statusCode)
   at Sdl.Web.Delivery.Service.AbstractODataService.HandleException(Exception e)
   at Sdl.Web.Delivery.Service.ODataV4Service.<>c__DisplayClass23_0`1.<Execute>b__0()
   at Sdl.Web.Delivery.Service.Utils.PerformRetry[T](Func`1 block, Int32 retryCount)
   at Sdl.Web.Delivery.Service.Utils.Retry[T](Func`1 block, Int32 retryCount, Boolean locking)
   at Sdl.Web.Delivery.Dynamic.Meta.AbstractMetaFactory.DoExecuteFunc[T](ODataV4ClientFunction func, Boolean expectSingleItem)
   at Sdl.Web.Delivery.Dynamic.Meta.AbstractMetaFactory.ExecuteFunc[T](ODataV4ClientFunction func, Boolean expectSingleItem)
   at Sdl.Web.Delivery.Dynamic.Meta.BinaryMetaFactory.GetMetaByURL(Int32 publicationId, String urlPath)
   at DD4T.Providers.Tridion95.CIL.TridionBinaryProvider.GetBinaryMetaByUrl(String url) in C:\projects\dd4t-providers-tridion9-5-cil\source\DD4T.Providers.Tridion9.5.CIL\TridionBinaryProvider.cs:line 210
   at DD4T.Factories.BinaryFactory.TryFindBinary(String url, String localPath, Boolean retrieveData, IBinary& binary) in C:\projects\dd4t-core\source\DD4T.Factories\BinaryFactory.cs:line 198

Could the token be expiring before all requests are handled? Are there other ways to find the cause of this issue?

Some extra information, we are using DD4T 2.5 and Tridion9.5

We have discovered that DD4T does not handle simultaneous requests properly. For each request to retrieve a binary file a new authentication token is requested. There can only be 1 valid token at a time so if the image is not retrieved fast enough then the following request invalidates the previous token causing the 401.

We are still looking for a solution to this.

  • My best guess to the cause of this issue is the authentication is not thread safe. When simultaneous requests are made to DD4T some will fail since the authentication is performed multiple times. I wrote a new binary file http module using graphQL and performing the authentication (token handling) myself and I ran into this problem too. Simultaneous requests would enter the same code block trying to get an authentication token. Only the last request would succeed since it invalidated the tokens of the previous requests. I surrounded the critical section with a semaphore and now it's working.
    – Rory
    Commented Nov 2, 2022 at 10:35


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.