Timeouts when calling Chrome Webdriver

a-coutinho
HOBBY

2 months ago

i'm using "undetected_chromedriver".

this produces the timeouts:

driver = uc.Chrome(desired_capabilities=setCapabilities(), options=setChromeOptions())
driver.get(url)

urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=45733): Read timed out. (read timeout=120)

what am i missing here?

Solved$10 Bounty

4 Replies

1topby
HOBBY

2 months ago

Hey, a-coutinho. Ensure your Chrome and ChromeDriver versions are compatible. Try downgrading to a known stable version pair (e.g., ChromeDriver 120 with Chrome 120).
You can try to add these arguments to your Chrome options before you create the Chrome driver instance. With undetected_chromedriver, this is typically done as follows:

import undetected_chromedriver as uc options = uc.ChromeOptions() options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument('--disable-gpu') driver = uc.Chrome(options=options)


a-coutinho
HOBBY

2 months ago

thanks for your reply. my code works well on my computer. i'm running windows10.

before the driver i already have this

options.add_argument("--FontRenderHinting[none]")

options.add_argument("--disable-background-timer-throttling")

options.add_argument("--disable-backgrounding-occluded-windows")

options.add_argument("--disable-crash-reporter")

options.add_argument("--disable-crashpad-for-testing")

options.add_argument("--disable-dev-shm-usage")

options.add_argument("--disable-extensions")

options.add_argument("--disable-logging")

options.add_argument("--disable-modal-animations")

options.add_argument("--disable-renderer-backgrounding")

options.add_argument("--disable-setuid-sandbox")

options.add_argument("--no-sandbox")

options.add_argument("--proxy-bypass-list=*")

options.add_argument("--proxy-server='direct://'")

options.add_argument("--start-maximized")

options.add_argument('--allow-running-insecure-content')

options.add_argument('--blink-settings=imagesEnabled=false')

options.add_argument('--disable-browser-side-navigation')

options.add_argument('--disable-dev-shm-usage')

options.add_argument('--disable-extensions')

options.add_argument('--disable-gpu')

options.add_argument('--disable-infobars')

options.add_argument('--disable-notifications')

options.add_argument('--ignore-certificate-errors')

options.add_argument('--no-sandbox')

options.add_argument('log-level=3')

here's my dockerfile:

FROM python:latest

ENV PYTHONUNBUFFERED True

ENV APP_HOME /app

WORKDIR $APP_HOME

COPY . ./

RUN pip install --no-cache-dir -r requirements.txt

RUN apt-get update && apt-get install -y wget unzip && \

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \

apt install -y ./google-chrome-stable_current_amd64.deb && \

rm google-chrome-stable_current_amd64.deb && \

apt-get clean

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]


2 months ago

Hi there

i think railway will terminate a process if it exceeds resources quota for RAM or CPU with no error message. Unless it has something to do with spinning up browsers in general because there was no spike in the Metrics tab

i had a similar issue with an app that would start a chrome browser in order to get a screenshot from a given URL but it failed every time. I ended up moving it to another provider but kept the DB here


a-coutinho

thanks for your reply. my code works well on my computer. i'm running windows10.before the driver i already have thisoptions.add_argument("--FontRenderHinting[none]")options.add_argument("--disable-background-timer-throttling")options.add_argument("--disable-backgrounding-occluded-windows")options.add_argument("--disable-crash-reporter")options.add_argument("--disable-crashpad-for-testing")options.add_argument("--disable-dev-shm-usage")options.add_argument("--disable-extensions")options.add_argument("--disable-logging")options.add_argument("--disable-modal-animations")options.add_argument("--disable-renderer-backgrounding")options.add_argument("--disable-setuid-sandbox")options.add_argument("--no-sandbox")options.add_argument("--proxy-bypass-list=*")options.add_argument("--proxy-server='direct://'")options.add_argument("--start-maximized")options.add_argument('--allow-running-insecure-content')options.add_argument('--blink-settings=imagesEnabled=false')options.add_argument('--disable-browser-side-navigation')options.add_argument('--disable-dev-shm-usage')options.add_argument('--disable-extensions')options.add_argument('--disable-gpu')options.add_argument('--disable-infobars')options.add_argument('--disable-notifications')options.add_argument('--ignore-certificate-errors')options.add_argument('--no-sandbox')options.add_argument('log-level=3')here's my dockerfile:FROM python:latestENV PYTHONUNBUFFERED TrueENV APP_HOME /appWORKDIR $APP_HOMECOPY . ./RUN pip install --no-cache-dir -r requirements.txtRUN apt-get update && apt-get install -y wget unzip && \wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \apt install -y ./google-chrome-stable_current_amd64.deb && \rm google-chrome-stable_current_amd64.deb && \apt-get cleanCMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

1topby
HOBBY

2 months ago

On Railway, Chrome and ChromeDriver must be compatible. If you install Chrome manually, you should also install the matching ChromeDriver version.

With undetected_chromedriver, you can specify the Chrome major version:
python
driver = uc.Chrome(options=options, version_main=120)
So, replace 120 with your installed Chrome's major version.

You can also to try increase Selenium-level timeouts to avoid premature failures:
python
driver.set_page_load_timeout(60) # seconds
driver.implicitly_wait(10)


Status changed to Solved chandrika about 1 month ago