简体   繁体   English

HTTPConnectionPool(host='localhost', port=4444)

[英]HTTPConnectionPool(host='localhost', port=4444)

i need run my script in docker container我需要在 docker 容器中运行我的脚本

version: "3"
services:
  chrome:
    image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210823
    shm_size: 2gb
    depends_on:
      - selenium-hub
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    ports:
      - "6900:5900"

  selenium-hub:
    image: selenium/hub:4.0.0-rc-1-prerelease-20210823
    container_name: selenium-hub
    ports:
      - "4444:4444"
   app:
        build:
            context: . 
        volumes:
            - . :/home/saimon/
        network_mode: "host"
        depends_on:
            - selenium-hub
            - chrome
        command:
            python3 app.py
        environment:
            - SELENIUM_REMOTE_HOST=selenium-hub

in my app i:在我的应用程序中我:

driver = webdriver.Remote(command_executor='http://selenium-hub:4444/wd/hub',
                                           desired_capabilities=DesiredCapabilities.CHROME, options=self.chrome_options)

i make: docker-compose build我制作:docker-compose 构建

sudo docker-compose run --rm app or docker-compose -f docker-compose.yml up sudo docker-compose run --rm app 或 docker-compose -f docker-compose.yml up

and show this error:并显示此错误:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='selenium-hub', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa7f86b3700>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='selenium-hub', port=4444): Max retries exceeded with url: /wd/hub/session (由 NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa7f86b3700>:无法建立新连接:[Errno -3] 名称解析暂时失败'))

Remove network_mode: "host" if you want to be able to connect to http://selenium-hub:4444 from the app container如果您希望能够从应用程序容器连接到http://selenium-hub:4444 ,请删除network_mode: "host"

You should also try using the env-var您还应该尝试使用 env-var

import os 

host = os.environ['SELENIUM_REMOTE_HOST']
driver = webdriver.Remote(command_executor='http://{}:4444/wd/hub'.format(host),
  ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由-ReadTimeoutError(HTTPConnectionPool(host = u&#39;localhost&#39;,port = 9200)引起的ConnectionTimeout:读取超时。(读取超时= 10) - ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host=u'localhost', port=9200): Read timed out. (read timeout=10)) ElasticSearch 超时错误:ReadTimeoutError(HTTPConnectionPool(host=&#39;localhost&#39;, port=9200): 读取超时。(读取超时=60)) - ElasticSearch Timeout Error: ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=60)) Pychrome ConnectionError: HTTPConnectionPool(host='localhost', port=8000): url: /json/new - Pychrome ConnectionError: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /json/new Python: HTTPConnectionPool(host=&#39;%s&#39;, port=80): - Python: HTTPConnectionPool(host='%s', port=80): urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=59587): Max retries exceeded with url using Selenium GeckoDriver Firefox - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=59587): Max retries exceeded with url using Selenium GeckoDriver Firefox Docker 中的 Scrapyd + Django:HTTPConnectionPool(主机 = '0.0.0.0',端口 = 6800)错误 - Scrapyd + Django in Docker: HTTPConnectionPool (host = '0.0.0.0', port = 6800) error 弹性搜索HTTPConnectionPool(host =&#39;127.0.0.1&#39;,port = 9200):超过最大重试次数 - Elastic Search HTTPConnectionPool(host='127.0.0.1', port=9200): Max retries exceeded raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=49426): - raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=49426): Erreur: HTTPConnectionPool(host='dnode2', port=9864): Max retries exceeded with url: /webhdfs - Erreur: HTTPConnectionPool(host='dnode2', port=9864): Max retries exceeded with url: /webhdfs urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&#39;127.0.0.1&#39;, port=49951): 使用 Selenium 和 Python 超过 url 的最大重试次数 - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=49951): Max retries exceeded with url with Selenium and Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM