JSREPORT PDF UPSTREAM ISSUE IN NGINX
-
Hi,
Getting error like follows, when sending api get request from client to print service.
Print service is running behind the proxy(nginx). From Print service we are calling jsreport client to generate the pdf.Error:
upstream prematurely closed connection while reading response header from upstream
Following is the code to generate PDF.
const jsreportClient = require('jsreport-client'); const client = jsreportClient(PRINT_API_BASE_URL, reportingServerUserInfo.userId, reportingServerUserInfo.password); let res1 = await client.render(reportData)
Please help us to fix it.
Thanks,
Surya prakash R
-
Please share the jsreport logs.
How does your nginx config look like?
How does thereportData
look like?
-
Hi,
We have reviewed today, it seems like jsreport is taking more than 40 seconds to generate the PDF without internal API calls in JSREPORT Studio. Is this time consuming may cause this error?
Following is the JS Report log
2020-11-30T13:37:08.147Z - info: Initializing jsreport@2.10.0 in staging mode using configuration file: jsreport.config.json
2020-11-30T13:37:08.148Z - info: Searching for available extensions in /app/
2020-11-30T13:37:08.151Z - info: Extensions location cache not found, crawling directories
2020-11-30T13:37:12.248Z - info: Found 35 extensions
2020-11-30T13:37:14.144Z - info: Setting http-server strategy for rendering
2020-11-30T13:37:15.644Z - info: Using extension authentication@2.6.0
2020-11-30T13:37:15.951Z - info: Using extension cli@2.2.5
2020-11-30T13:37:15.957Z - info: Using extension debug@2.1.3
2020-11-30T13:37:15.961Z - info: Using extension express@2.8.0
2020-11-30T13:37:16.257Z - info: Using extension freeze@2.0.0
2020-11-30T13:37:16.258Z - info: Using extension handlebars@2.1.0
2020-11-30T13:37:16.259Z - info: Using extension import-export@2.1.0
2020-11-30T13:37:16.949Z - info: Using extension jsrender@2.1.1
2020-11-30T13:37:16.950Z - info: Using extension tags@2.5.0
2020-11-30T13:37:16.955Z - info: Using extension templates@2.4.0
2020-11-30T13:37:17.043Z - info: Using extension authorization@2.4.0
2020-11-30T13:37:17.051Z - info: Using extension base@2.0.2
2020-11-30T13:37:17.055Z - info: Using extension browser-client@2.2.2
2020-11-30T13:37:17.059Z - info: Using extension child-templates@1.4.0
2020-11-30T13:37:17.145Z - info: Using extension chrome-pdf@1.9.0
2020-11-30T13:37:17.843Z - info: Using extension data@2.4.0
2020-11-30T13:37:17.843Z - info: Using extension docx@2.8.0
2020-11-30T13:37:17.850Z - info: Using extension fs-store@2.9.0
2020-11-30T13:37:19.150Z - info: Using extension licensing@2.2.3
2020-11-30T13:37:19.151Z - info: Using extension pdf-utils@1.9.0
2020-11-30T13:37:19.646Z - info: Using extension pptx@0.7.0
2020-11-30T13:37:19.649Z - info: Using extension reports@2.5.0
2020-11-30T13:37:19.651Z - info: Using extension static-pdf@0.4.0
2020-11-30T13:37:19.652Z - info: Using extension studio@2.10.1
2020-11-30T13:37:20.058Z - info: Using extension text@2.0.0
2020-11-30T13:37:20.060Z - info: Using extension version-control@1.5.1
2020-11-30T13:37:20.562Z - info: Using extension assets@1.7.0
2020-11-30T13:37:20.652Z - info: Using extension html-to-xlsx@2.8.0
2020-11-30T13:37:23.543Z - info: html-to-xlsx detected chrome as available html engine
2020-11-30T13:37:23.644Z - info: Using extension scheduling@2.5.0
2020-11-30T13:37:23.757Z - info: Using extension scripts@2.6.0
2020-11-30T13:37:23.844Z - info: Using extension studio-theme-dark@0.3.0
2020-11-30T13:37:23.846Z - info: Using extension xlsx@2.5.0
2020-11-30T13:37:25.745Z - info: Using extension public-templates@2.2.0
2020-11-30T13:37:25.747Z - info: Using extension resources@2.1.0
2020-11-30T13:37:25.749Z - info: Using extension sample-template@2.6.0
2020-11-30T13:37:25.754Z - info: Using general timeout for rendering (reportTimeout: 60000)
2020-11-30T13:37:25.754Z - info: Using fs provider for template store.
2020-11-30T13:37:25.857Z - info: fs store is persisting using fs
2020-11-30T13:37:25.944Z - info: fs store is synchronizing using fs
2020-11-30T13:37:26.152Z - info: fs store is loading data
2020-11-30T13:37:27.755Z - info: fs store is initialized successfully
2020-11-30T13:37:28.145Z - info: Configuring routes for existing express app.
2020-11-30T13:37:28.358Z - info: Mounting routes under appPath (/api/report/portal).
2020-11-30T13:37:28.359Z - info: Using existing server instance.
2020-11-30T13:37:28.445Z - info: fs store emits sockets to synchronize underlying changes with studio
2020-11-30T13:37:28.645Z - info: Verifying license key free
2020-11-30T13:37:29.523Z - info: Starting one month enterprise trial
2020-11-30T13:37:29.538Z - info: reporter initialized
2020-11-30T13:37:46.450Z - info: Starting rendering request 1 (user: kanadmin)
2020-11-30T13:37:46.455Z - info: Rendering template { name: main, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:37:54.749Z - info: Starting rendering request 2 (user: kanadmin)
2020-11-30T13:37:54.754Z - info: Rendering template { name: noteinfo, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:37:55.745Z - info: Rendering request 2 finished in 996 ms
2020-11-30T13:38:06.446Z - info: pdf-utils is starting pdf processing
2020-11-30T13:38:11.749Z - info: Starting rendering request 3 (user: kanadmin)
2020-11-30T13:38:11.751Z - info: Rendering template { name: header-footer, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:38:11.844Z - info: Starting rendering request 4 (user: kanadmin)
2020-11-30T13:38:11.844Z - info: Rendering template { name: clientSignature, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:38:12.054Z - info: Rendering request 4 finished in 206 ms
2020-11-30T13:38:20.049Z - info: Rendering request 3 finished in 8300 ms
2020-11-30T13:38:24.252Z - info: Starting rendering request 5 (user: kanadmin)
2020-11-30T13:38:24.252Z - info: Rendering template { name: encounterinfo, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:38:31.947Z - info: Rendering request 5 finished in 7694 ms
2020-11-30T13:38:34.851Z - info: pdf-utils pdf processing was finished
2020-11-30T13:38:34.852Z - info: Rendering request 1 finished in 48403 ms
2020-11-30T13:38:50.513Z - info: Starting rendering request 6 (user: kanadmin)
2020-11-30T13:38:50.543Z - info: Rendering template { name: main, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:38:50.558Z - info: Starting rendering request 7 (user: kanadmin)
2020-11-30T13:38:50.558Z - info: Rendering template { name: noteinfo, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:38:50.749Z - info: Rendering request 7 finished in 191 ms
2020-11-30T13:39:00.745Z - info: pdf-utils is starting pdf processing
2020-11-30T13:39:02.455Z - info: Starting rendering request 8 (user: kanadmin)
2020-11-30T13:39:02.457Z - info: Rendering template { name: header-footer, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:39:02.547Z - info: Starting rendering request 9 (user: kanadmin)
2020-11-30T13:39:02.548Z - info: Rendering template { name: clientSignature, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:39:02.557Z - info: Rendering request 9 finished in 10 ms
2020-11-30T13:39:10.045Z - info: Rendering request 8 finished in 7592 ms
2020-11-30T13:39:12.152Z - info: Starting rendering request 10 (user: kanadmin)
2020-11-30T13:39:12.154Z - info: Rendering template { name: encounterinfo, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:39:20.145Z - info: Rendering request 10 finished in 7993 ms
2020-11-30T13:39:21.753Z - info: pdf-utils pdf processing was finished
2020-11-30T13:39:21.754Z - info: Rendering request 6 finished in 31241 ms
2020-11-30T13:39:37.768Z - info: Starting rendering request 11 (user: kanadmin)
2020-11-30T13:39:37.769Z - info: Rendering template { name: main, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:39:37.848Z - info: Starting rendering request 12 (user: kanadmin)
2020-11-30T13:39:37.851Z - info: Rendering template { name: noteinfo, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:39:38.146Z - info: Rendering request 12 finished in 298 ms
2020-11-30T13:39:47.945Z - info: pdf-utils is starting pdf processing
2020-11-30T13:39:48.659Z - info: Starting rendering request 13 (user: kanadmin)
2020-11-30T13:39:48.744Z - info: Rendering template { name: header-footer, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:39:48.756Z - info: Starting rendering request 14 (user: kanadmin)
2020-11-30T13:39:48.758Z - info: Rendering template { name: clientSignature, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:39:49.053Z - info: Rendering request 14 finished in 297 ms
2020-11-30T13:39:57.748Z - info: Rendering request 13 finished in 9088 ms
2020-11-30T13:40:00.058Z - info: Starting rendering request 15 (user: kanadmin)
2020-11-30T13:40:00.143Z - info: Rendering template { name: encounterinfo, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:40:08.844Z - info: Rendering request 15 finished in 8786 ms
2020-11-30T13:40:09.944Z - info: pdf-utils pdf processing was finished
2020-11-30T13:40:09.945Z - info: Rendering request 11 finished in 32177 ms
2020-11-30T13:40:38.066Z - error: Error when processing OData PATCH: /portal/odata/scripts(wxicK6ph2QvQNHE4) Error: Entity (_id: wxicK6ph2QvQNHE4) was modified previously by another source
at module.exports (/app/node_modules/jsreport-core/lib/util/createError.js:11:13)
at Reporter.createError (/app/node_modules/jsreport-core/lib/reporter.js:332:12)
at AsyncFunction.<anonymous> (/app/node_modules/jsreport-studio/lib/studio.js:468:30)
2020-11-30T13:41:19.897Z - info: Starting rendering request 16 (user: kanadmin)
2020-11-30T13:41:19.901Z - info: Rendering template { name: main, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:41:19.951Z - info: Starting rendering request 17 (user: kanadmin)
2020-11-30T13:41:19.951Z - info: Rendering template { name: noteinfo, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:41:20.057Z - info: Rendering request 17 finished in 105 ms
2020-11-30T13:41:30.147Z - info: pdf-utils is starting pdf processing
2020-11-30T13:41:32.150Z - info: Starting rendering request 18 (user: kanadmin)
2020-11-30T13:41:32.152Z - info: Rendering template { name: header-footer, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:41:32.157Z - info: Starting rendering request 19 (user: kanadmin)
2020-11-30T13:41:32.159Z - info: Rendering template { name: clientSignature, recipe: html, engine: handlebars, preview: true }
2020-11-30T13:41:32.648Z - info: Rendering request 19 finished in 491 ms
2020-11-30T13:41:39.443Z - info: Rendering request 18 finished in 7294 ms
2020-11-30T13:41:41.245Z - info: Starting rendering request 20 (user: kanadmin)
2020-11-30T13:41:41.246Z - info: Rendering template { name: encounterinfo, recipe: chrome-pdf, engine: handlebars, preview: true }
2020-11-30T13:41:49.247Z - info: Rendering request 20 finished in 8002 ms
2020-11-30T13:41:51.843Z - info: pdf-utils pdf processing was finished
2020-11-30T13:41:51.943Z - info: Rendering request 16 finished in 31946 msWe will send the reportdata shortly.
Can you please help me with this information.
Thanks,
Surya Prakash
-
Here they recommend increasing the proxy timeouts in the nginx config. You can try it out.
https://stackoverflow.com/a/48858256/1660996
-
Hi,
We have tried those steps also. It was not worked for us.JSReport will take time to generate PDF?
-
Do you get the same error also on the "Hello world" template? Is it related to the long rendering?
JSReport will take time to generate PDF?
This is primarily based on what you are rendering..
-
I am trying to render a content "test". No sample data and script.
In jsreport studio it is taking 20 second of average.
same when i am trying with api request same error is occuring.
-
following is the nginx configuration.
upstream apigatewaydemo1 { server xx.x.xx.xxx:31345; } server { listen 80; server_name www.ttttttt.com; return 301 https://$host$request_uri; location / { proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://xx.x.xx.xxx:31345; } } server { listen 443; server_name www.ttttttt.com; ssl on; ssl_certificate /dfaetce/sslse/certificate.pem; ssl_certificate_key /dfaetce/sslse/private-key.pem; location / { proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://xx.x.xx.xxx:31345; } }
-
Hi,
Getting one more exception when i try to add a new entity. Getting following error and service is getting stopped.
2020-12-01T14:23:39.751Z - error: uncaughtException: k[i].lastIndexOf is not a function date=Tue Dec 01 2020 19:53:39 GMT+0530 (India Standard Time), pid=22960, uid=null, gid=null, cwd=C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc, execPath=C:\Program Files\nodejs\node.exe, version=v12.18.3, argv=[C:\Program Files\nodejs\node.exe, C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\index], rss=87404544, heapTotal=53637120, heapUsed=48542448, external=2354305, arrayBuffers=775512, loadavg=[0, 0, 0], uptime=4244822
TypeError: k[i].lastIndexOf is not a function
at keys (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\simple-odata-server\lib\insert.js:5:14)
at sortProperties (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\simple-odata-server\lib\insert.js:16:15)
at C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\simple-odata-server\lib\insert.js:47:16
at tryCatcher (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\util.js:16:23)
at Promise.successAdapter [as _fulfillmentHandler0] (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\nodeify.js:23:30)
at Promise._settlePromise (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\promise.js:566:21)
at Promise._settlePromise0 (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\promise.js:694:18)
at _drainQueueStep (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\async.js:138:12)
at _drainQueue (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\async.js:131:9)
at Async._drainQueues (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\async.js:147:5)
at Immediate.Async.drainQueues (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\bluebird\js\release\async.js:17:14)
at processImmediate (internal/timers.js:456:21)
2020-12-01T14:24:50.435Z - error: Error when processing OData POST: /portal/odata/templates Error: Entity with name "testtemplate" already exists in the /GeneratedReports folder.
at module.exports (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\jsreport-core\lib\util\createError.js:11:13)
at Reporter.createError (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\jsreport-core\lib\reporter.js:332:12)
at validateDuplicatedName (C:\Users\suryaprakash\Documents\WorkArea\KTBitBucket\print-svc\node_modules\jsreport-core\lib\folders\validateDuplicatedName.js:87:20)
-
Hi,
can i have the update on this?
-
I am trying to render a content "test". No sample data and script.
In jsreport studio it is taking 20 second of average.This is a very long time and the first problem to solve.
What is your hw machine setup? Even a single CPU machine needs to handle it in a one second.
Do you run in docker? What if you run without nginx, do you have the same results?I see you posted one log where it looks you run on Linux and one when you run on Windows.
I guess windows is just a dev machine. There you have also the same performance problems?