Search code examples
.net2sxcimageflow

Issue with Imageflow image resizing on Production Server using Oqtane with 2sxc


We are currently experiencing an issue with our Oqtane v3.4.3 site which utilizes 2sxc v16.00.00. Our 2sxc Image Gallery app, which relies on the ToSic.Imageflow.Oqtane v1.0.4, is encountering a problem specific to the production environment on our newly set up Windows Server Core dedicated for Oqtane.

The development process ran smoothly without any glitches. However, upon moving the site to our production server, we noticed that certain new images return an HTTP 500 error when resized using query string parameters.

Here's what we have verified so far:

  1. All Imageflow DLL files are correctly published.
  2. All image files are located in the correct directories within the Oqtane folder structure, with proper permissions, and the images themselves are not corrupted.
  3. The 'imageflow_hybrid_cache' folder, which stores resized images, has preserved cache files from the development environment, which work as expected. However, when we need to generate a new image cache due to new resize parameters or a new image, we get an HTTP 500 error instead of the picture. File system permissions for 'imageflow_hybrid_cache' have been confirmed to be correct, and our Oqtane app pool can write in that folder.
  4. To better understand the HTTP 500 error, we enabled .NET logging in the web.config file under the /logs/ folder.

The critical part of the log is as follows:

[Log details]

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 POST https://app07.live.oqtane.me/_blazor/negotiate?negotiateVersion=1 text/plain;charset=UTF-8 0
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://app07.live.oqtane.me/app/Content/adam/Z5ftErsabkSolmWsOhyWJw/Image/Image07-WebP.webp?w=800&h=432&quality=75&mode=crop&scale=both - -
ImageflowRewriteMiddleware.Before:?w=800&h=432&quality=75&mode=crop&scale=both
ImageflowRewriteMiddleware.After:?w=800&h=432&quality=75&mode=crop&scale=both&png.quality=75&webp.quality=75
info: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[7]
      Identity.Application was not authenticated. Failure message: Unprotect ticket failed
fail: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2]
      Connection ID "16573246629528731845", Request ID "400000c6-0000-e600-b63f-84710c7967bb": An unhandled exception was thrown by the application.
      System.DllNotFoundException: Looking for "imageflow.dll" RID="win-x64", IsUnix=False, IsDotNetCore=True RelativeSearchPath=""
Before searching: Unable to load DLL 'imageflow' or one of its dependencies: The specified module could not be found. (0x8007007E)
File not found: \\live\w\app07\x64\imageflow.dll
File not found: \\live\w\app07\imageflow.dll
Error "The specified module could not be found." (126) loading imageflow from \\live\w\app07\runtimes\win-x64\native\imageflow.dll
> You may need to install the C Runtime from https://aka.ms/vs/16/release/vc_redist.x64.exe
   at Imageflow.Bindings.NativeMethods.imageflow_context_create(UInt32 imageflowAbiVerMajor, UInt32 imageflowAbiVerMinor)
        at Imageflow.Bindings.JobContextHandle.<>c.<.ctor>b__0_0()
         at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)
      
         at Imageflow.Bindings.LoadLogger.RaiseException()
         at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)
         at Imageflow.Bindings.JobContextHandle..ctor()
         at Imageflow.Bindings.JobContext..ctor()
         at Imageflow.Fluent.ImageJob.FinishAsync(JobExecutionOptions executionOptions, SecurityOptions securityOptions, CancellationToken cancellationToken)
         at Imageflow.Server.ImageJobInfo.ProcessUncached()
         at Imageflow.Server.ImageflowMiddleware.<>c__DisplayClass15_0.<<ProcessWithStreamCache>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Imazen.HybridCache.AsyncCache.<>c__DisplayClass35_0.<<GetOrCreateBytes>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Imazen.Common.Concurrency.AsyncLockProvider.TryExecuteAsync(String key, Int32 timeoutMs, CancellationToken cancellationToken, Func`1 success)
         at Imazen.HybridCache.AsyncCache.GetOrCreateBytes(Byte[] key, AsyncBytesResult dataProviderCallback, CancellationToken cancellationToken, Boolean retrieveContentType)
         at Imazen.HybridCache.HybridCache.GetOrCreateBytes(Byte[] key, AsyncBytesResult dataProviderCallback, CancellationToken cancellationToken, Boolean retrieveContentType)
         at Imageflow.Server.ImageflowMiddleware.ProcessWithStreamCache(HttpContext context, String cacheKey, ImageJobInfo info)
         at Imageflow.Server.ImageflowMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

This part of the log suggests that the system cannot find 'imageflow.dll', even though we've confirmed that the DLL is in place.

Has anyone else faced a similar issue or can provide insights into this problem? We appreciate any assistance you can provide.


Solution

  • My guess is that the error log is a bit misleading.

    I believe ImageFlow (the image resizer) requires the standard C++ runtimes from Microsoft. These are often pre-installed because some other software requires them. But if you have a brand new Windows Server it could be that they are missing.

    So my guess is that without these, the system is searching the wrong folders for the native DLLs and not finding them. I also assume that just moving the files won't work.

    So my recommendation: install the C++ Runtimes from https://aka.ms/vs/16/release/vc_redist.x64.exe and everything should work.