Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDriverException: Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127 #323

Open
yonipick opened this issue Dec 27, 2021 · 6 comments

Comments

@yonipick
Copy link

using selenium 4.1.0
chromdriver = https://chromedriver.storage.googleapis.com/95.0.4638.69/chromedriver_linux64.zip
headless-chromium = v1.0.0-57

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

def lambda_handler(event, context):
options = webdriver.ChromeOptions()
options.binary_location = '/opt/headless-chromium'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--single-process')
options.add_argument('--disable-dev-shm-usage')

driver = webdriver.Chrome(
    '/opt/chromedriver',
    chrome_options=options,

)
driver.get('https://www.google.com/')

driver.close();
driver.quit();

response = {
    "statusCode": 200,
    "body": "Selenium Headless Chrome Initialized"
}

return response

get error

Response
{
"errorMessage": "Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127\n",
"errorType": "WebDriverException",
"requestId": "75128542-446b-4cff-a28e-6406e1ba41f4",
"stackTrace": [
" File "/var/task/lambda_function.py", line 14, in lambda_handler\n driver = webdriver.Chrome(\n",
" File "/opt/python/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in init\n super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",\n",
" File "/opt/python/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in init\n self.service.start()\n",
" File "/opt/python/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start\n self.assert_process_still_running()\n",
" File "/opt/python/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running\n raise WebDriverException(\n"
]
}

@umihico
Copy link

umihico commented Jan 31, 2022

This is not a direct solution, but you can just use native chromium instead of serverless-chrome. Does this alternative way achieve your needs? I have a demo repository here.
https://github.com/umihico/docker-selenium-lambda/

@Usmanfawad
Copy link

@umihico , I used native chromium that you've mentioned and the file size exceeds. Asking me to use an s3 bucket. I don't have rights to use an s3 bucket, only lambda rights. Please guide. Thanks.

@umihico
Copy link

umihico commented Jun 16, 2023

You can import code from S3 or lambda layer, or docker image. My solution above is docker. You can try docker image or lambda layer if S3 is not option.
@Usmanfawad

@Usmanfawad
Copy link

@umihico I did use lambda layers but the size exceeds 10 MB. HOW do i upload a docker image? Your help will be appreciated.

@umihico
Copy link

umihico commented Jun 16, 2023

It says lambda layer size is 250MB.
how about this one?
https://github.com/shelfio/chrome-aws-lambda-layer

@Usmanfawad
Copy link

@umihico Thanks! Works just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants