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

Error in lambda_handler: Message: Service /opt/chromedriver unexpectedly exited. Status code was: -5 #298

Open
raghavvijind opened this issue Jan 7, 2025 · 2 comments

Comments

@raghavvijind
Copy link

I keep on getting the above error.
Python 3.13.0
chromium 131.0.6778.204
chromedriver 131.0.6778.204
selenium 4.27.1

Dockerfile:
FROM public.ecr.aws/lambda/python@sha256:f5b51b377b80bd303fe8055084e2763336ea8920d12955b23ef8cb99dda56112 as build
RUN dnf install -y unzip &&
curl -Lo "/tmp/chromedriver-linux64.zip" "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chromedriver-linux64.zip" &&
curl -Lo "/tmp/chrome-linux64.zip" "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chrome-linux64.zip" &&
unzip /tmp/chromedriver-linux64.zip -d /opt/ &&
unzip /tmp/chrome-linux64.zip -d /opt/

FROM public.ecr.aws/lambda/python@sha256:f5b51b377b80bd303fe8055084e2763336ea8920d12955b23ef8cb99dda56112
RUN dnf install -y atk cups-libs gtk3 libXcomposite alsa-lib
libXcursor libXdamage libXext libXi libXrandr libXScrnSaver
libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb
xorg-x11-xauth dbus-glib dbus-glib-devel nss mesa-libgbm
RUN pip install selenium==4.27.1
COPY --from=build /opt/chrome-linux64 /opt/chrome
COPY --from=build /opt/chromedriver-linux64 /opt/
COPY lambda_package/ /var/task/
CMD [ "lambda_function.lambda_handler" ]

Code:
options = webdriver.ChromeOptions()
service = webdriver.ChromeService("/opt/chromedriver")

options.binary_location = '/opt/chrome/chrome'
options.add_argument("--headless=new")
options.add_argument('--no-sandbox')
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1280x1696")
options.add_argument("--single-process")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-dev-tools")
options.add_argument("--no-zygote")
options.add_argument(f"--user-data-dir={mkdtemp()}")
options.add_argument(f"--data-path={mkdtemp()}")
options.add_argument(f"--disk-cache-dir={mkdtemp()}")
options.add_argument("--remote-debugging-port=9222")


chrome = webdriver.Chrome(options=options, service=service) 
print("initialised")
# chrome.maximize_window()
return chrome

Please help me identify the issue

@umihico
Copy link
Owner

umihico commented Jan 7, 2025

You customized code or purely following README instruction?

@kzkzzk
Copy link

kzkzzk commented Feb 28, 2025

I encountered the same error. If you build and run locally on arm64, please try using public.ecr.aws/lambda/python:3.13-x86_64 in Dockerfile. It works for me.

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