docker-selenium-lambda icon indicating copy to clipboard operation
docker-selenium-lambda copied to clipboard

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

Open raghavvijind opened this issue 9 months ago • 3 comments

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

raghavvijind avatar Jan 07 '25 15:01 raghavvijind