I'm receiving a 502 / Bad Gateway response ONLY when I add a header to my phantom-pdf report



  • I'm receiving a 502 / Bad Gateway response ONLY when I add a header to my phantom-pdf report:

    Unable to render template. <html>
    <head><title>502 Bad Gateway</title></head>
    <body bgcolor="white">
    <center><h1>502 Bad Gateway</h1></center>
    <hr><center>nginx/1.13.8</center>
    </body>
    </html>

    I'm using the jsreport.Client v2.0.2 / ReportingService.RenderAsync(string templateShortid, string jsonData, null) to make the call. I'm making the call from ASP.NET Core 2.1 running on the full .NET Framework 4.7.

    Without the header in phantom-pdf, the call works fine. When I add the header in jsreport studio, the call works great. But when I call it from my server, I receive the bad gateway response.

    Here is my log from a call where I received that bad gateway error:

    +0 Starting rendering request 54278
    +4 Rendering template {shortid:SkhDhiX0G, recipe:phantom-pdf,engine:handlebars}
    +6 Inline data specified.
    +11 Executing script H1xyvW55Ae
    +77 Resources not defined for this template.
    +80 Rendering engine handlebars
    +92 Compiled template not found in the cache, compiling
    +101 Replaced images []
    +101 Executing recipe phantom-pdf
    +102 Starting child request to render pdf header
    +106 Starting rendering request 54279
    +110 Rendering template {shortid:SkhDhiX0G, recipe:html,engine:handlebars}
    +111 Inline data specified.
    +116 Executing script H1xyvW55Ae
    +134 Resources not defined for this template.
    +139 Rendering engine handlebars
    +162 Taking compiled template from engine cache
    +164 Replaced images []
    +165 Executing recipe html
    +165 Skipping storing report.
    +166 Rendering request finished 54279
    +176 Rendering request 54279 finished in 37 ms
    +178 Starting child request to render pdf footer
    +182 Starting rendering request 54280
    +185 Rendering template {shortid:SkhDhiX0G, recipe:html,engine:handlebars}
    +186 Inline data specified.
    +191 Executing script H1xyvW55Ae
    +208 Resources not defined for this template.
    +211 Rendering engine handlebars
    +239 Taking compiled template from engine cache
    +359 Replaced images []
    +360 Executing recipe html
    +360 Skipping storing report.
    +361 Rendering request finished 54280
    +367 Rendering request 54280 finished in 155 ms
    +473 Converting in http server based phantomjs 1.9.8
    +474 Request file:///%2Ftmp%2Fe3691040-58f7-11e8-b6be-fb387c609d7fhtml.html
    +575 phantom-pdf recipe finished with 4 pages generated
    +576 Skipping storing report.

    This is the log from a call when the phantom-pdf header is not present and the call returned successfully:

    +0 Starting rendering request 326882
    +5 Rendering template {shortid:SkhDhiX0G, recipe:phantom-pdf,engine:handlebars}
    +6 Inline data specified.
    +12 Executing script H1xyvW55Ae
    +66 Resources not defined for this template.
    +76 Rendering engine handlebars
    +667 Compiled template not found in the cache, compiling
    +758 Replaced images []
    +759 Executing recipe phantom-pdf
    +760 Starting child request to render pdf footer
    +771 Starting rendering request 326883
    +784 Rendering template {shortid:SkhDhiX0G, recipe:html,engine:handlebars}
    +786 Inline data specified.
    +792 Executing script H1xyvW55Ae
    +850 Resources not defined for this template.
    +860 Rendering engine handlebars
    +879 Compiled template not found in the cache, compiling
    +883 Replaced images []
    +884 Executing recipe html
    +884 Skipping storing report.
    +885 Rendering request finished 326883
    +891 Rendering request 326883 finished in 36 ms
    +1752 Converting in http server based phantomjs 1.9.8
    +1753 Request file:///%2Ftmp%2Ff94f60b0-58f9-11e8-8a39-f15f3d321df0html.html
    +1868 phantom-pdf recipe finished with 4 pages generated
    +1869 Skipping storing report.

    These are the addition log elements from the call when there is a header. I don't see anything interesting here.

    +102 Starting child request to render pdf header
    +106 Starting rendering request 54279
    +110 Rendering template {shortid:SkhDhiX0G, recipe:html,engine:handlebars}
    +111 Inline data specified.
    +116 Executing script H1xyvW55Ae
    +134 Resources not defined for this template.
    +139 Rendering engine handlebars
    +162 Taking compiled template from engine cache
    +164 Replaced images []
    +165 Executing recipe html
    +165 Skipping storing report.
    +166 Rendering request finished 54279
    +176 Rendering request 54279 finished in 37 ms



  • Looking into it....



  • jsreportonline webserver rejects the response because of too big response header containing render logs. The jsreport client requests this by default.
    Until we fix this problem please use the following workaround.

    var result = rs.RenderAsync(new RenderRequest()
                {
                    Template = new Template
                    {
                        Name = "template name"
                    },
                    Data = new
                    {
    
                    },
                    Options = new RenderOptions
                    {
                        Debug = new DebugOptions
                        {
                            LogsToResponseHeader = false
                        }
                    }
                }).Result;
    


  • Worked great. Thank you Jan.



  • i am facing the same error .... how to solve in .net core???


Log in to reply
 

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