resourcetimeout option vs scripts timeout in configuration



  • The error I am getting is:
    2018-01-03T17:23:42.753Z - error: Error when processing render request Error during rendering report: Timeout error during executing script Error: Timeout error during executing script
    at Timeout._onTimeout (C:\ifolder\iroot\jsReport\node_modules\script-manager\lib\manager-processes.js:24:8)
    at ontimeout (timers.js:380:14)
    at Timer.unrefdHandle (timers.js:486:5) requestId=1


  • administrators

    ok, then you should configure scripts timeout, can you please show the content of the script that you are using in your template? maybe there is some error in there.



  • Thanks for the clarification. Is there any advantage in using "resourceTimeout".

    My script is :
    function beforeRender(req, res, done) {
    // get search parameters

    let searchParams = {
            'prjId':req.data.prjId || '7473',
            'respCtr':req.data.respCtr || '000020',
            'negateRespCtr':req.data.negateRespCtr || 'false',
            'fmsId':req.data.fmsId || 'N0058',
            'beginPayPeriod': req.data.beginPayPeriod || '',
            'endPayPeriod':  req.data.endPayPeriod || ''
        };
    req.data.searchParams = searchParams;    
    
    request.get({
        url: `http://localhost:3000/xxx/xxx/xxxx`,
        qs:   req.data.searchParams || {},
        json: true
    }, (err, response, body) => {
        if (err) done(err);
        
        req.data.transactions = body || [];
        done();
    });
    

    }


  • administrators

    Is there any advantage in using "resourceTimeout".

    for your case not, because your error is just about the script, not phantomjs.

    how long is your server at http://localhost:3000/xxx/xxx/xxxx taking to respond? did you test it separately? (for example using a tool like postman) how much data is the http://localhost:3000/xxx/xxx/xxxx returning? a lot of records? maybe you just need to increase scripts timeout to a big value if the http://localhost:3000 server just takes too long.



  • Sometimes it can return 31000 records and sometimes 350 records roughly... and it does take long long time to process data even to get back with 350 records...
    I think I got my answer, increase script timeout and if jsreport takes longer after getting data then increase phantom timeout.
    Do correct me if I am wrong.

    Thanks a whole lot for your answers,
    Rashmi


  • administrators

    I think I got my answer, increase script timeout and if jsreport takes longer after getting data then increase phantom timeout.

    yes, exactly. additionally if you want to configure jsreport for the best performance you should probably take a look at this topic for some hints.

    hope i was able to help you.



  • Thanks a lot. One more Question: to handle socket hang up error, which configuration should I increase.
    the query took 716 secs. and I have set scripts timeout to 13 mins.
    Here is error:
    2018-02-12T19:19:26.812Z - warn: Error when processing render request Error during rendering report: socket hang up Error: socket hang up
    at createHangUpError (_http_client.js:253:15)
    at Socket.socketOnEnd (_http_client.js:345:23)

    and configuration:

    "phantom": {
    "strategy": "dedicated-process",
    "timeout": 180000
    },
    "tasks": {
    "strategy": "dedicated-process",
    "timeout": 100000,
    "allowedModules": []
    },
    "scripts": {
    "allowedModules": ["request", "http", "process"],
    "timeout": 1300000
    },


  • administrators

    hi! @rashmim00 the request and http (depending which one you are directly using) module also have a timeout configuration which you can set when calling the method that does the http request, for example for the request module you can see here the timeout option listed which you can specify when calling the method



  • I did specify timeout but still gets the socket error which is strange.

    request.get({
    url: http://localhost:3000/xxxx/xxx/xxxxxxxx,
    qs: req.data.searchParams || {},
    timeout : 1500000,
    json: true
    }, (err, response, body) => {}



  • When I set timeout at my express server level then this problem goes away.
    Thank you for all of your help.


Log in to reply
 

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