Oddly enough, I saw a couple recommendations to run the following command, and it actually solved the problem. Just wanted to share what worked for me.
yum install libXScrnSaver
Oddly enough, I saw a couple recommendations to run the following command, and it actually solved the problem. Just wanted to share what worked for me.
yum install libXScrnSaver
Hi - thanks for the response. Ive tried quite a few things but still receiving the same error. Here are some notes:
[UPDATE] - solved with an additional command listed in another post below
tried running your suggested commands, everything either said "complete" or "nothing to do" so should be good there.
Based on the error regarding the troubleshooting section i followed these two steps:
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-aws-ec2-instance-running-amazon-linux
Is there a certain directory that i should be running the commands in? Ive been doing it in the same directory as everything regarding the jsreport app
Is puppeteer needed for this? that seems to the case and wondering if maybe we can just unlink that
Here is my current package.json
{
"name": "jsreport-server",
"main": "server.js",
"scripts": {
"start": "node server",
"jsreport": "jsreport"
},
"jsreport": {
"entryPoint": "server.js"
},
"dependencies": {
"archiver": "^5.3.0",
"jsreport": "^2.11.0",
"jsreport-phantom-pdf": "2.6.1",
"jsreport-xlsx": "^2.5.0",
"moment": "^2.29.1",
"ncp": "^2.0.0",
"request": "^2.88.2"
}
}
I've recently installed the on-premise version into an Amazon EC2 instance, following the steps outline here https://jsreport.net/learn/amazon-linux.
The step in which chrome is supposed to be installed doesnt seem to be picking up the installation as we are getting the error listed at the bottom. It appears to maybe be a linking / config issue but not quite sure what to try. Is there anything that might stand out as an easy adjustment to get jsreport to recognize the installation?
wget -qO- https://intoli.com/install-google-chrome.sh | bash
Error: Failed to launch chrome!
/home/ec2-user/jsreportapp/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/home/ec2-user/jsreportapp/node_modules/puppeteer/lib/Launcher.js:348:14)
at Interface.helper.addEventListener (/home/ec2-user/jsreportapp/node_modules/puppeteer/lib/Launcher.js:337:50)
at emitNone (events.js:111:20)
at Interface.emit (events.js:208:7)
at Interface.close (readline.js:368:8)
at Socket.onend (readline.js:147:10)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Jan - thanks for the input, I was finally able to get to the bottom of this and sharing my outcome below for anyone else that may end up in the same position.
The AWS PHP SDK utilizes Guzzle for handling the request and response to Lambda, so in the response the actual payload is private/hidden unless you use the mechanism provided by the SDK to extract it from the response. Below is an example of how this was handled
$client = LambdaClient::factory(array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials'=> array(
'key' => getenv('AWS_ACCESS_KEY_ID'),
'secret' => getenv('AWS_SECRET_ACCESS_KEY'),
)
));
$result = $client->invoke(array(
'FunctionName' => 'jsfunction',
'InvocationType' => "RequestResponse",
'Payload' => $data, // your json payload
));
// Get the payload from the object
$body = json_decode($result['Payload']);
// Base64 Decode the PDF/excel data
$pdf_data = base64_decode($body->body);
HTML seemed to produce the same response, when digging into the the cloudwatch logs I am noticing an error after "reporter initialized" that says the response below. As a precursor to this, I had fully tested it using localhost and it worked fine, so not sure if there is something missing when createLambdaPackage.js was ran
2021-03-16T00:49:19.589Z d95bf476-ac1f-4f85-b967-71cae1033ab7 ERROR Invoke Error {
"errorType": "TypeError",
"errorMessage": "Cannot read property 'template' of undefined",
"stack": [
"TypeError: Cannot read property 'template' of undefined",
" at module.exports (/opt/nodejs/node_modules/jsreport-core/lib/render/request.js:13:43)",
" at module.exports (/opt/nodejs/node_modules/jsreport-core/lib/render/render.js:114:19)",
" at Reporter.render (/opt/nodejs/node_modules/jsreport-core/lib/reporter.js:324:12)",
" at Runtime.exports.handler (/var/task/index.js:29:30)"
]
}
I am trying to get the on-premise version to work with Lambda, everything from the tutorial worked great, however when I invoke the function via the AWS PHP SDK (IAM user), I get a 200 response but nothing in the response payload which Im assuming is where the PDF / Excel data would live. Below is an example of that request/response, and the only thing that is different seems to be that Im invoking from PHP and not node. Any pointers on what could lead this type of scenario would be much appreciated.
Some initial thoughts are:
How its being invoked
$client = LambdaClient::factory(array(
'version'=> 'latest',
'region' => 'us-east-1',
'credentials'=> array(
'key' => getenv('AWS_ACCESS_KEY_ID_LAMBDA'),
'secret' => getenv('AWS_SECRET_ACCESS_KEY_LAMBDA'),
)
));
$result = $client->invoke(array(
'FunctionName' => 'jsfunction',
"InvocationType" => "RequestResponse",
'Payload' => $this->setup_data,
));
The request
{
"template":{
"shortid":"MY-SHORT-ID",
"recipe":"phantom-pdf",
"engine":"handlebars",
"phantom":{
"margin":{
"top":"0.2cm",
"bottom":"0.2cm",
"left":"0.2cm",
"right":"0.2cm"
}
}
},
"options":{
"Content-Disposition":"attachment; filename=MY-FILE-NAME.pdf"
},
"data":{REMOVED-FOR-PRIVACY
}
}
The response
Model Data
----------
Data can be retrieved from the model object using the get() method of the
model (e.g., `$result->get($key)`) or "accessing the result like an
associative array (e.g. `$result['key']`). You can also execute JMESPath
expressions on the result data using the search() method.
{
"Payload": {},
"StatusCode": 200,
"FunctionError": "Unhandled",
"LogResult": "",
"ExecutedVersion": "$LATEST",
"@metadata": {
"statusCode": 200,
"effectiveUri": "https:\/\/lambda.us-east-1.amazonaws.com\/2015-03-31\/functions\/jsfunction\/invocations",
"headers": {
"date": "Mon, 15 Mar 2021 04:53:08 GMT",
"content-type": "application\/json",
"content-length": "604",
"connection": "keep-alive",
"x-amzn-requestid": "{{request-id-removed}}",
"x-amz-function-error": "Unhandled",
"x-amzn-remapped-content-length": "0",
"x-amz-executed-version": "$LATEST",
"x-amzn-trace-id": "{{trace-id-removed}}"
},
"transferStats": {
"http": [
[]
]
}
}
}