JSReport-core problem with production es6



  • So, I deployed me node express app with jsreport inside but when I try to run the app I get this error

    http://prntscr.com/kqwhhe

    How can I make jsreport-core run in the production mode? Or something that doesn't break with es6


  • administrators

    hi! your production server is probably using an older version of node.js, jsreport-core/jsreport v2 needs node.js >=8.9 as the minimal version. check the version installed in your production server and if it is less that the supported version then you will need to upgrade your node.js installation first.



  • @djapecom You are right, I had older version of node. Now I got a question. I want to use a jsreport-core in my nodejs app. But the only thing that this app wants to do is just take the api request and returns a render pdf as a stream or whatever. I just have a problem with setup.

    And I made a small thing like that with express, but the problem that I have when I deployed in on azure windows web app with node >=8.9 is that making request to
    the endpoint which takes used the jsreport-core, it hangs up for 2 minutes and then just timesout. I don't know, maybe my setup is wrong or maybe the jsreport core is using some different ports? It works locally, but not on azure.

    Here is the code I have used

    app.js

    var JSREPORT_CONFIG = Object.freeze({
    phantom: {
    strategy: "phantom-server"
    },
    templatingEngines: {
    numberOfWorkers: 1,
    strategy: "http-server",
    timeout: 60000
    }
    });

    var jsreport = require('jsreport-core')(JSREPORT_CONFIG);
    var express = require('express');
    var bodyParser = require("body-parser");
    var compression = require('compression');
    var helmet = require('helmet');
    var cors = require('cors');
    var routes = require('./jsreport.pdf.api/routes');

    var app = express();
    app.use(cors());
    app.use(compression());
    app.use(helmet());
    app.use(bodyParser.json({ limit: '100mb' }));
    app.use(bodyParser.urlencoded({ limit: '100mb', extended: true }));
    app.use(routes);

    var PORT = process.env.PORT || 3000;
    app.listen(PORT);

    route
    router.get("/api/generate", pdf_controller.pdfGetInstance);

    and here is the controller
    'use strict';

    var jsreport = require('jsreport-core')();

    jsreport.use(require('jsreport-phantom-pdf')());
    jsreport.use(require('jsreport-handlebars')());
    jsreport.init();

    var ENGINE = "handlebars";
    var RECIPE = "phantom-pdf";

    exports.pdfInstance = function (req, res) {
    var _req$body = req.body,
    data = _req$body.data,
    template = _req$body.template,
    scripts = _req$body.scripts;
    var phantom = template.phantom,
    helpers = template.helpers,
    content = template.content;
    var header = phantom.header,
    footer = phantom.footer,
    headerHeight = phantom.headerHeight,
    footerHeight = phantom.footerHeight,
    format = phantom.format;

    jsreport.render({
        template: {
            content: content,
            engine: ENGINE,
            recipe: RECIPE,
            phantom: {
                header: header,
                footer: footer,
                headerHeight: headerHeight,
                footerHeight: footerHeight,
                format: format
            },
            helpers: helpers
        },
        data: data,
        options: {
            timeout: 60000,
            reportName: "Pdf Document"
        }
    })
    
    .then(function (resp) {
        res.send(resp.content);
    })
    
    .catch(function (resp) {
        res.send(resp);
    });
    

    };

    And as said. It works perfectly fine localy. On azure api endpoints other than this one works aswell. But the one with jsreport.render just hangs for 120000ms and timesout. I just want it to finally work :D, bought the license key but cannot make a use of it x_ x


  • administrators

    hi!

    And I made a small thing like that with express, but the problem that I have when I deployed in on azure windows web app with node >=8.9 is that making request to
    the endpoint which takes used the jsreport-core, it hangs up for 2 minutes and then just timesout. I don't know, maybe my setup is wrong or maybe the jsreport core is using some different ports?

    i don't see anything that looks bad with your code, however maybe the problem is related to azure limitations with phantom, you can find here another user that discover a problem and fixed by changing the azure plan, maybe you can try that.


Log in to reply
 

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