Error rendering PDF in ASP.NET Core application in on server.



  • Hello,

    I'm getting an exception when rendering a PDF on IIS, works file locally but I get this exception when running in my App Service.

    jsreport.Local.JsReportBinaryException: Error rendering report: instance has been daemonized and initialized successfully* (pid: 17484)A critical error occurred while trying to execute the render command: spawn UNKNOWN (1). caused by error (1) -> meta = {"remoteStack":"Error: spawn UNKNOWN\n    at _errnoException (util.js:1022:11)\n    at ChildProcess.spawn (internal/child_process.js:323:11)\n    at Object.exports.spawn (child_process.js:503:9)\n    at Launcher.launch (jsreportRuntime.js:313974:40)\n    at <anonymous>"}, stack = Error:     at responseToBuffer ([eval]:42206:29)    at concat ([eval]:42259:40)    at ConcatStream.<anonymous> ([eval]:13929:43)    at emitNone (events.js:111:20)    at ConcatStream.emit (events.js:208:7)    at finishMaybe ([eval]:88932:14)    at afterWrite ([eval]:88794:3)    at _combinedTickCallback (internal/process/next_tick.js:144:20)    at process._tickCallback (internal/process/next_tick.js:180:9)
       at jsreport.Local.Internal.LocalUtilityReportingService.RenderAsync(String requestString, CancellationToken ct)
       at GasPos.Customer.Portal.Pages.Private.Reports.ReportModelBase`1.RenderPDFContentAsync(String content) in /home/vsts/work/1/s/GasPos.Customer.Portal/Pages/Private/Reports/ReportModelBase.cs:line 123
       at GasPos.Customer.Portal.Pages.Private.Reports.ReportModelBase`1.OnPostAsync() in /home/vsts/work/1/s/GasPos.Customer.Portal/Pages/Private/Reports/ReportModelBase.cs:line 116
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject)
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeHandlerMethodAsync()
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeNextPageFilterAsync()
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeInnerFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
       at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
    

    This is the code to render the PDF.

    public class PDFRenderService
        : IPDFRenderService
    {
        ILocalUtilityReportingService _renderService = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();
    
        Task<Report> IPDFRenderService.RenderAsync(RenderRequest request, CancellationToken ct)
        {
            return _renderService.RenderAsync(request, ct);
        }
    }
    

    It looks like JSReport is spawning a child process that has access rights issues.
    Is there some way to render without creating a child process?
    Is there some configuration I'm missing?



  • The error you posted is just stack trace missing the actual error message.

    There is no way to run without child processes. It is a quite heavy thing.
    The jsreport .net sdk first takes the big compressed stream from the dll manifest.
    This gets extracted into temp and it contains jsreport.exe which is recompiled nodejs together with jsreport.
    The exe then have inside bundled chrome browser which is used to convert html to pdf.
    You see quite complicated and the sdk needs to run the jsreport.exe child process which needs to run chrome.exe afterward.



  • @jan_blaha Sorry for missing that data in my post. I had the "```" on the same line as the error message and for some reason it removed all that text. Please see my original post again as the error is now present with the call stack.



  • A bit confused now. You complain about error when using IIS, but the stacktrace contains path which isn't windows like, but more unix like.
    By App Service you mean Azure app service? Please describe more your environment.



  • Yes, the ASP.Net Core application is running in an Azure App service on Windows 32bit. Latest version of everything, Microsoft Windows NT 10.0.14393.0, IIS 10.0 all managed by Azure.

    Code is targeting netcoreapp2.2
    jsreport.AspNetCore Version="2.0.0"
    jsreport.Binary Version="2.3.1"
    jsreport.Local Version="2.0.0"



  • Ok. Unfortunately, Azure App service blocks chrome when you use windows. It runs only on the linux based app service.
    See this in the docs

    https://jsreport.net/learn/dotnet-local#azure-web-apps



  • Ah, okay well that's unfortunate. I'll have to figure out what to do from here then.



  • You can also use jsreport instance remotely. I mean run it on another vm if you have one, or in another linux based app service. Or even use https://jsreportonline.net
    Instead of using jsreport.Local.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.