resourcetimeout option vs scripts timeout in configuration
-
Hi,
I am new to jsReport. Sorry if its already been asked.
In my situation, the data is collected from many places and takes time and often there is a timeout situation. What is a good place to configure timeout. "resourcetimeout":90000 as request options or in dev.config file where I have configured
"scripts": {
"allowedModules": ["request", "http", "process"],
"timeout": 90000
},.
or Do I need to increase timeout for phantom.Thanks a lot,
Rashmi
-
hi!
resourcetimeout
does not exists as a top level configuration in dev.config.json, you should try increasing the phantom timeout configuration.
-
Thanks for quick reply. I meant resourcetimeout here - let dataObj = { "template":{"shortid":"......."}, "resourcetimeout":90000} when I am calling the report.
What is the difference in scripts timeout and phantom. If I increase timeout value does it impact small reports.
Thank you,
Rashmi
-
"resourcetimeout" does not exists as a configuration in request level too. can you please instead post here the jsreport logs that you are getting that includes the full error message?
What is the difference in scripts timeout and phantom.
script timeout means that jsreport will wait "x" time before it throws a timeout error if you don't call
done()
in a jsreport script, or if that script just take more than "x" time. scripts can run before and after phantomjs renderingphantom timeout means that jsreport will wait "x" time before it throws a timeout error if phantom rendering is not finished at that time.
If I increase timeout value does it impact small reports.
no, it should not impact any report that does not take too long to render. that config just throw errors for reports that take too long to render
-
I meant resourcetimeout here - let dataObj = { "template":{"shortid":"......."}, "resourcetimeout":90000}
just to clarify, the correct option is
resourceTimeout
notresourcetimeout
and it lives inside phantom object, which should be specified inside template object.let dataObj = { "template":{ "shortid":".......", "phantom": { "resourceTimeout":90000 } } }
-
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
-
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 parameterslet 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(); });
}
-
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 thehttp://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
-
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
},
-
hi! @rashmim00 the
request
andhttp
(depending which one you are directly using) module also have atimeout
configuration which you can set when calling the method that does the http request, for example for therequest
module you can see here thetimeout
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.