Chromium with agouti pkg on AWS Lambda doesn't work (couldn't take screenshot)











up vote
0
down vote

favorite












I'm trying to use headless-chromium on AWS Lambda with Golang and sclevine/agouti.
I confirmed that chromedriver is executed on Lambda using exec.Command.



Error occurred when taking screenshot, but, I'm not sure headless-chromium is started properly. No error occurred when executing driver.Start() and driver.NewPage. Start message like ChromeDriver 2.43.600233, onlt local connection is allowed was not shown.



Code and outputs are like below.



func main() {
lambda.Start(handler)
}

func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
os.Setenv("PATH", os.Getenv("PATH") + ":/var/task")

out1, err := exec.Command("/var/task/chromedriver", "-v").Output()
if err != nil {
log.Fatal(err)
}
log.Printf("exec chromedriver %sn", string(out1))
// 2018/11/08 13:12:05 exec chromedriver ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)

opts := agouti.Option{
agouti.ChromeOptions(
"args", string{
"headless",
"no-default-browser-check",
"verbose",
"no-sandbox",
"no-first-run",
"disable-default-apps",
"disable-popup-blocking",
"disable-translate",
"disable-background-timer-throttling",
"disable-renderer-backgrounding",
"disable-device-discovery-notifications",
},
),
agouti.Desired(
agouti.Capabilities{
"loggingPrefs": map[string]string{
"browser": "INFO",
},
},
),
}
opts = append(opts,
agouti.ChromeOptions(
"binary", "/var/task/headless-chromium",
))
driver := agouti.NewWebDriver("http://{{.Address}}", string{"/var/task/chromedriver", "--port={{.Port}}"}, opts...)
if err := driver.Start(); err != nil {
log.Fatalf("failed to start driver:%v", err)
}
p, err := driver.NewPage()
if err != nil {
log.Fatalf("failed to open page:%v", err)
}
if err := page.Navigate("https://www.google.com/"); err != nil {
log.Fatalf("failed to navigate:%v", err)
}
if err := page.Screenshot("/tmp/top.jpg"); err != nil {
log.Fatalf("failed to take ss:%v", err)
// 2018/11/08 13:12:07 failed to take ss:failed to retrieve
// screenshot: unexpected response:
// {
// "sessionId": "30c4fc0e74ce6c865ced6c8443e873bc",
// "status": 6,
// "value": {
// "message": "invalid session idn (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.14.72-68.55.amzn1.x86_64 x86_64)"
// }
//}
}
}


I got binaries of headless-shell and chromedriver like below.



curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip -d artifact/
rm chromedriver.zip
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-54/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
unzip headless-chromium.zip -d artifact/
rm headless-chromium.zip


I deployed artifacts using SAM and artifacts were deployed under var/tasks/ on Lambda.



Please help me...










share|improve this question
























  • I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
    – Toshinori Sugita
    Nov 8 at 15:12










  • Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
    – ThomasP1988
    Nov 12 at 13:12










  • Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
    – Toshinori Sugita
    Nov 14 at 14:31















up vote
0
down vote

favorite












I'm trying to use headless-chromium on AWS Lambda with Golang and sclevine/agouti.
I confirmed that chromedriver is executed on Lambda using exec.Command.



Error occurred when taking screenshot, but, I'm not sure headless-chromium is started properly. No error occurred when executing driver.Start() and driver.NewPage. Start message like ChromeDriver 2.43.600233, onlt local connection is allowed was not shown.



Code and outputs are like below.



func main() {
lambda.Start(handler)
}

func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
os.Setenv("PATH", os.Getenv("PATH") + ":/var/task")

out1, err := exec.Command("/var/task/chromedriver", "-v").Output()
if err != nil {
log.Fatal(err)
}
log.Printf("exec chromedriver %sn", string(out1))
// 2018/11/08 13:12:05 exec chromedriver ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)

opts := agouti.Option{
agouti.ChromeOptions(
"args", string{
"headless",
"no-default-browser-check",
"verbose",
"no-sandbox",
"no-first-run",
"disable-default-apps",
"disable-popup-blocking",
"disable-translate",
"disable-background-timer-throttling",
"disable-renderer-backgrounding",
"disable-device-discovery-notifications",
},
),
agouti.Desired(
agouti.Capabilities{
"loggingPrefs": map[string]string{
"browser": "INFO",
},
},
),
}
opts = append(opts,
agouti.ChromeOptions(
"binary", "/var/task/headless-chromium",
))
driver := agouti.NewWebDriver("http://{{.Address}}", string{"/var/task/chromedriver", "--port={{.Port}}"}, opts...)
if err := driver.Start(); err != nil {
log.Fatalf("failed to start driver:%v", err)
}
p, err := driver.NewPage()
if err != nil {
log.Fatalf("failed to open page:%v", err)
}
if err := page.Navigate("https://www.google.com/"); err != nil {
log.Fatalf("failed to navigate:%v", err)
}
if err := page.Screenshot("/tmp/top.jpg"); err != nil {
log.Fatalf("failed to take ss:%v", err)
// 2018/11/08 13:12:07 failed to take ss:failed to retrieve
// screenshot: unexpected response:
// {
// "sessionId": "30c4fc0e74ce6c865ced6c8443e873bc",
// "status": 6,
// "value": {
// "message": "invalid session idn (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.14.72-68.55.amzn1.x86_64 x86_64)"
// }
//}
}
}


I got binaries of headless-shell and chromedriver like below.



curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip -d artifact/
rm chromedriver.zip
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-54/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
unzip headless-chromium.zip -d artifact/
rm headless-chromium.zip


I deployed artifacts using SAM and artifacts were deployed under var/tasks/ on Lambda.



Please help me...










share|improve this question
























  • I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
    – Toshinori Sugita
    Nov 8 at 15:12










  • Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
    – ThomasP1988
    Nov 12 at 13:12










  • Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
    – Toshinori Sugita
    Nov 14 at 14:31













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to use headless-chromium on AWS Lambda with Golang and sclevine/agouti.
I confirmed that chromedriver is executed on Lambda using exec.Command.



Error occurred when taking screenshot, but, I'm not sure headless-chromium is started properly. No error occurred when executing driver.Start() and driver.NewPage. Start message like ChromeDriver 2.43.600233, onlt local connection is allowed was not shown.



Code and outputs are like below.



func main() {
lambda.Start(handler)
}

func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
os.Setenv("PATH", os.Getenv("PATH") + ":/var/task")

out1, err := exec.Command("/var/task/chromedriver", "-v").Output()
if err != nil {
log.Fatal(err)
}
log.Printf("exec chromedriver %sn", string(out1))
// 2018/11/08 13:12:05 exec chromedriver ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)

opts := agouti.Option{
agouti.ChromeOptions(
"args", string{
"headless",
"no-default-browser-check",
"verbose",
"no-sandbox",
"no-first-run",
"disable-default-apps",
"disable-popup-blocking",
"disable-translate",
"disable-background-timer-throttling",
"disable-renderer-backgrounding",
"disable-device-discovery-notifications",
},
),
agouti.Desired(
agouti.Capabilities{
"loggingPrefs": map[string]string{
"browser": "INFO",
},
},
),
}
opts = append(opts,
agouti.ChromeOptions(
"binary", "/var/task/headless-chromium",
))
driver := agouti.NewWebDriver("http://{{.Address}}", string{"/var/task/chromedriver", "--port={{.Port}}"}, opts...)
if err := driver.Start(); err != nil {
log.Fatalf("failed to start driver:%v", err)
}
p, err := driver.NewPage()
if err != nil {
log.Fatalf("failed to open page:%v", err)
}
if err := page.Navigate("https://www.google.com/"); err != nil {
log.Fatalf("failed to navigate:%v", err)
}
if err := page.Screenshot("/tmp/top.jpg"); err != nil {
log.Fatalf("failed to take ss:%v", err)
// 2018/11/08 13:12:07 failed to take ss:failed to retrieve
// screenshot: unexpected response:
// {
// "sessionId": "30c4fc0e74ce6c865ced6c8443e873bc",
// "status": 6,
// "value": {
// "message": "invalid session idn (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.14.72-68.55.amzn1.x86_64 x86_64)"
// }
//}
}
}


I got binaries of headless-shell and chromedriver like below.



curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip -d artifact/
rm chromedriver.zip
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-54/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
unzip headless-chromium.zip -d artifact/
rm headless-chromium.zip


I deployed artifacts using SAM and artifacts were deployed under var/tasks/ on Lambda.



Please help me...










share|improve this question















I'm trying to use headless-chromium on AWS Lambda with Golang and sclevine/agouti.
I confirmed that chromedriver is executed on Lambda using exec.Command.



Error occurred when taking screenshot, but, I'm not sure headless-chromium is started properly. No error occurred when executing driver.Start() and driver.NewPage. Start message like ChromeDriver 2.43.600233, onlt local connection is allowed was not shown.



Code and outputs are like below.



func main() {
lambda.Start(handler)
}

func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
os.Setenv("PATH", os.Getenv("PATH") + ":/var/task")

out1, err := exec.Command("/var/task/chromedriver", "-v").Output()
if err != nil {
log.Fatal(err)
}
log.Printf("exec chromedriver %sn", string(out1))
// 2018/11/08 13:12:05 exec chromedriver ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)

opts := agouti.Option{
agouti.ChromeOptions(
"args", string{
"headless",
"no-default-browser-check",
"verbose",
"no-sandbox",
"no-first-run",
"disable-default-apps",
"disable-popup-blocking",
"disable-translate",
"disable-background-timer-throttling",
"disable-renderer-backgrounding",
"disable-device-discovery-notifications",
},
),
agouti.Desired(
agouti.Capabilities{
"loggingPrefs": map[string]string{
"browser": "INFO",
},
},
),
}
opts = append(opts,
agouti.ChromeOptions(
"binary", "/var/task/headless-chromium",
))
driver := agouti.NewWebDriver("http://{{.Address}}", string{"/var/task/chromedriver", "--port={{.Port}}"}, opts...)
if err := driver.Start(); err != nil {
log.Fatalf("failed to start driver:%v", err)
}
p, err := driver.NewPage()
if err != nil {
log.Fatalf("failed to open page:%v", err)
}
if err := page.Navigate("https://www.google.com/"); err != nil {
log.Fatalf("failed to navigate:%v", err)
}
if err := page.Screenshot("/tmp/top.jpg"); err != nil {
log.Fatalf("failed to take ss:%v", err)
// 2018/11/08 13:12:07 failed to take ss:failed to retrieve
// screenshot: unexpected response:
// {
// "sessionId": "30c4fc0e74ce6c865ced6c8443e873bc",
// "status": 6,
// "value": {
// "message": "invalid session idn (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.14.72-68.55.amzn1.x86_64 x86_64)"
// }
//}
}
}


I got binaries of headless-shell and chromedriver like below.



curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip -d artifact/
rm chromedriver.zip
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-54/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
unzip headless-chromium.zip -d artifact/
rm headless-chromium.zip


I deployed artifacts using SAM and artifacts were deployed under var/tasks/ on Lambda.



Please help me...







go aws-lambda chromium agouti






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 12:05

























asked Nov 8 at 13:44









Toshinori Sugita

11




11












  • I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
    – Toshinori Sugita
    Nov 8 at 15:12










  • Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
    – ThomasP1988
    Nov 12 at 13:12










  • Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
    – Toshinori Sugita
    Nov 14 at 14:31


















  • I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
    – Toshinori Sugita
    Nov 8 at 15:12










  • Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
    – ThomasP1988
    Nov 12 at 13:12










  • Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
    – Toshinori Sugita
    Nov 14 at 14:31
















I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
– Toshinori Sugita
Nov 8 at 15:12




I checked the downloaded binary (stable build of headless chromium github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-55 ) on EC2 (Amazon Linux). ./headless-chromium --headless --disable-gpu --window-size=1024,768 --hide-scrollbars --screenshot='yahoo.png' yahoo.co.jp This command was successful. I got yahoo.png via scp command and was able to open on mac. I think chromium binary itself has no problem.
– Toshinori Sugita
Nov 8 at 15:12












Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
– ThomasP1988
Nov 12 at 13:12




Hi Toshinori, have you checked the .serverless folder and see if your binary file is attached? Do you have any error message in cloudwatch?
– ThomasP1988
Nov 12 at 13:12












Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
– Toshinori Sugita
Nov 14 at 14:31




Thank you for your comment! I don't use .serverless, but how can I confirm my binary is files are attached or not? Errors are shown like comment out right under log.Fatalf("failed to take ss:%v", err) in code above.
– Toshinori Sugita
Nov 14 at 14:31

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209001%2fchromium-with-agouti-pkg-on-aws-lambda-doesnt-work-couldnt-take-screenshot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209001%2fchromium-with-agouti-pkg-on-aws-lambda-doesnt-work-couldnt-take-screenshot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings