I am getting this error frequently not everytime.
HTTPConnectionPool(host=’localhost’, port=32817): Max retries exceeded
with url: /session/286f9b1508aa3fab78fee8a606577194/execute/sync
(Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection
object at 0x7fd56e845400>: Failed to establish a new connection:
[Errno 111] Connection refused’))
When I send request again, it works. But doesn’t work when I send subsequent requests.
What i am doing wrong.
I am using these Chrome options.
"httpProxy": proxy_string
options.proxy = Proxy(proxies)
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors')
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument("--incognito")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
options.add_argument("--start-maximized")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-extensions")
options.add_argument("--no-zygote")
options.add_argument("--disable-notifications")`
<code> proxies: dict = {
"httpProxy": proxy_string
}
options.proxy = Proxy(proxies)
# Other Chrome options
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors')
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument("--incognito")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
options.add_argument("--start-maximized")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-extensions")
options.add_argument("--no-zygote")
options.add_argument("--disable-notifications")`
</code>
proxies: dict = {
"httpProxy": proxy_string
}
options.proxy = Proxy(proxies)
# Other Chrome options
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors')
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
options.add_argument("--incognito")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
options.add_argument("--start-maximized")
options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-extensions")
options.add_argument("--no-zygote")
options.add_argument("--disable-notifications")`
Using Chrome version as 126.0.6478.55
Please let me know if any further info required.
I have tried hitting request again and again. Sometimes its working and sometimes giving exception.
I am doing one thing here
def is_instance_valid(instance):
instance.execute_script("return true;")
logging.info("Browser instance is valid")
except WebDriverException:
logging.error("Browser instance is invalid")
<code>@staticmethod
def is_instance_valid(instance):
try:
instance.execute_script("return true;")
logging.info("Browser instance is valid")
return True
except WebDriverException:
logging.error("Browser instance is invalid")
return False
</code>
@staticmethod
def is_instance_valid(instance):
try:
instance.execute_script("return true;")
logging.info("Browser instance is valid")
return True
except WebDriverException:
logging.error("Browser instance is invalid")
return False
Can this piece of code does this?
I am downloading chrome and driver version like this in my docker file.
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
&& apt-get install -y google-chrome-stable
# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt
RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp
RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& rm -rf /tmp/chromedriver-linux64.zip
<code>RUN apt-get update && apt-get install -y wget gnupg2 curl unzip
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
&& apt-get update
&& apt-get install -y google-chrome-stable
# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt
RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp
RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& rm -rf /tmp/chromedriver-linux64.zip
</code>
RUN apt-get update && apt-get install -y wget gnupg2 curl unzip
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
&& apt-get update
&& apt-get install -y google-chrome-stable
# Check Chrome installation
RUN echo google-chrome --version
RUN google-chrome --version | awk '{print $3}' > /tmp/chrome_version.txt
RUN wget -N "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.55/linux64/chromedriver-linux64.zip" -P /tmp
RUN unzip /tmp/chromedriver-linux64.zip -d /tmp
RUN mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
&& chmod 0755 /usr/local/bin/chromedriver
&& rm -rf /tmp/chromedriver-linux64.zip