Skip to content

Help on "Message: chrome not reachable" #164

@ahirnish

Description

@ahirnish

Hi @umihico,

I am using your selenium-docker solution to run headless Chrome browser in AWS Lambda for my project. It is a great help already :)

I need a bit of support and your expert advice on this setup if you dont mind. I'll give a bit of context what I am doing so that its easy for you to give advice. -

I created this headless browser lambda and I am using it to render some images from a URL and then save these images as screenshots in S3. This whole process runs for a big number of URLs (like a stream of URLs to this lambda as input) via AWS Step Functions.
Although its working but there are always about 50-60 URLs (total URLs 3000) which runs into these following messages -

  • Message: chrome not reachable
  • Message: unknown error: unhandled inspector error: {"code":-32000,"message":"Unable to capture screenshot"}
  • Message: unknown error: cannot activate web view

I am trying to understand the problems as to why it happens only for few URLs and not for all. Your help will help me understand more.

Hope to hear back from you. Thank you.

This is my Dockerfile -

#based on https://github.com/umihico/docker-selenium-lambda
FROM public.ecr.aws/lambda/python:3.8 as build

# download chrome binaries, unzip them desired location
RUN yum install -y unzip && \
    curl -Lo "/tmp/chromedriver.zip" "https://chromedriver.storage.googleapis.com/98.0.4758.48/chromedriver_linux64.zip" && \
    curl -Lo "/tmp/chrome-linux.zip" "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F950363%2Fchrome-linux.zip?alt=media" && \
    unzip /tmp/chromedriver.zip -d /opt/ && \
    unzip /tmp/chrome-linux.zip -d /opt/

# as of feb 2023 python3.8 was stable
FROM public.ecr.aws/lambda/python:3.8

# install necessary packages for running chrome
RUN yum install 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 -y

# install selenium
RUN pip install selenium

COPY --from=build /opt/chrome-linux /opt/chrome
COPY --from=build /opt/chromedriver /opt/

#COPY lambda_function.py requirements.txt ./
# copy requirements
COPY . requirements.txt ./

COPY mraid.js ./tmp/

# install requirements
RUN python3.8 -m pip install -r requirements.txt -t .

# Command can be overwritten by providing a different command in the template directly.
# entry point
CMD ["lambda_function.lambda_handler"]

This is more like help and not an issue. Please suggest a better way to ask this help if this is no the right place. THank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions