Followed "Run Chrome extensions with Python Selenium on AWS Lambda" and it works Locally but not once Deployed to AWS #103
-
I followed the "Run Chrome extensions with Python Selenium on AWS Lambda" tutorial which by the way was super helpful, and it worked for me when I use sam local invoke to run it locally. However, once I use 'sam deploy" to deploy it and try testing it on AWS, I get the error: "errorMessage": "Message: unknown error: Chrome failed to start: exited abnormally\n (unknown error: unable to discover open pages)\n (The process started from chrome location opt/chrome/stable/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n which I've tried to solve by switching versions of Chrome, Chromium and the driver that I use, but I keep running into the same problem. I was wondering if you've run this on AWS and if it worked for you and if so what I might be doing wrong. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hey Jeff. At the time of writing this article it did work, but it is extremely unstable and I'm not surprised you're facing crashes. The problem is usually either correctly placing chrome/chromedriver with relevant permissions or Lambda's own runtime compilation and configuration which is made worse by unstable Selenium-Python bindings. Bottom line is, the docker file & script will work well on ECS but will be unstable on Lambda and is not fit for production. Since then I'm exploring using Puppeteer which has more stable APIs and has a better chance of working on pure Lambda. |
Beta Was this translation helpful? Give feedback.
-
Hello, I had a similar issue (but with an empty error message on AWS) and I managed to get it working by dropping python to 3.8 and locking selenium to 3.141.0. I got this idea by checking what is max version AWS is putting into their canaries: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html BR |
Beta Was this translation helpful? Give feedback.
-
For me it seems the issue is the fact that you need this argument to run selenium in Lambda: chrome_options.add_argument("--single-process"). However, including that argument breaks the extension loading process. |
Beta Was this translation helpful? Give feedback.
-
Does anyone have an update on this? Using selenium with chrome extensions on lambda is perfect for my use-case. I am considering moving to Fargate but its a little less inline with what I am trying to do. Quick Note, Things I have tried: The most frustrating part is that when I run the docker container locally, all is well. The extension works headless and everything completes as needed. As soon as the driver loads in, I get a message that says
|
Beta Was this translation helpful? Give feedback.
Hey Jeff. At the time of writing this article it did work, but it is extremely unstable and I'm not surprised you're facing crashes. The problem is usually either correctly placing chrome/chromedriver with relevant permissions or Lambda's own runtime compilation and configuration which is made worse by unstable Selenium-Python bindings.
Bottom line is, the docker file & script will work well on ECS but will be unstable on Lambda and is not fit for production.
Since then I'm exploring using Puppeteer which has more stable APIs and has a better chance of working on pure Lambda.