Run parallel instances



  • How can I run various parallel instances of jsReports in .net sdk?
    I have that code:

    ILocalUtilityReportingService rs = new LocalReporting()
                    .KillRunningJsReportProcesses()
                    .UseBinary(JsReportBinary.GetBinary())
                    .Configure(cfg => cfg.AllowedLocalFilesAccess().BaseUrlAsWorkingDirectory())
                    .AsUtility()
                    .Create();
    
                try
                {
                    jsreport.Types.Report report = rs.RenderAsync(new RenderRequest
                    {
                        Template = new Template
                        {
                            Chrome = new Chrome()
                            {
                                Landscape = printReportDto.Landscape,
                                Format = printReportDto.Format,
                                MarginTop = "0px",
                                MarginRight = "0px",
                                MarginBottom = "0px",
                                MarginLeft = "0px",
                                DisplayHeaderFooter = false
                            },
                            Engine = Engine.Handlebars,
                            Recipe = Recipe.ChromePdf,
                            Content = template,
                            Helpers = ReportHelper.MainFunctions,
                            PdfOperations = pdfOperations
                        },
                        Data = data
                    }).Result;
    
                    return report.Content.ToArray();
                }
                finally
                {
                    rs.KillAsync().Wait();
                }
    

    In the second instance, throw an exception:

    "JsReportBinaryException: Error rendering report: instance has been daemonized and initialized successfully (pid: 15936)A critical error occurred while trying to execute the render command: read ECONNRESET (1). caused by error (1) -> meta = {"code":"ECONNRESET","errno":"ECONNRESET","syscall":"read"}, stack = Error: read ECONNRESET at _errnoException (util.js:1022:11) "

    Any help?
    Thanks



  • You should initialize the reporting service just once during the app startup.
    Afterwards, you can use RenderAsync in parallel.


Log in to reply
 

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