ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.97k stars 1.16k forks source link

can't run same user_data_dir again #1380

Open Jiroun opened 1 year ago

Jiroun commented 1 year ago

the problem is first time I run the program with user_data_dir

options = uc.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

driver =uc.Chrome(options = options, user_data_dir="/root/Aladdin")

then I do my stuff like login or something

if I run the program again to same folder ( but this time shoud be already logged in to my website)

this problem appear

driver =uc.Chrome(options = options, user_data_dir="/root/Aladdin") File "/usr/local/lib/python3.10/dist-packages/undetected_chromedriver/__init__.py", line 443, in __init__ super(Chrome, self).__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chrome/webdriver.py", line 49, in __init__ super().__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chromium/webdriver.py", line 54, in __init__ super().__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__ self.start_session(capabilities) File "/usr/local/lib/python3.10/dist-packages/undetected_chromedriver/__init__.py", line 674, in start_session super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 291, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:58797 from chrome not reachable

forget to mention _ problem happen on linux only , on windows works fine

rafamelo01 commented 1 year ago

Same here, maybe is a port issues on Linux.

Jiroun commented 1 year ago

Same here, maybe is a port issues on Linux.

yes , for me I just moved to windows

23ari commented 1 year ago

I have the same problem with a Linux docker container and natively on macOS. I only experience this issue when running in headless mode. Has anyone found a workaround or solution?

chjtwork commented 1 year ago

I think this problem may be related to the version of chrome, these days I have been using uc on windows, everything was fine a few days ago, now I have the same problem, the only change is that my chrome automatically updated to version 115.

rafamelo01 commented 1 year ago

In windows it is updated automatically and with that the problem is solved, is that it? Already in linux, chrome is not updated automatically and from there the problems begin to arise, do you think this is the error?

momo286 commented 1 year ago

I have the same problem, i use UC on Ubuntu. The solution i found is that everytime i open UC, i create a random folder, and then tell UC to use it.

basedir2=Path( __file__ ).parent.absolute().joinpath(str(''.join(random.choices(string.ascii_lowercase, k=7))))
try:
    os.mkdir(basedir2)
except:
    pass
options = uc.ChromeOptions()
driver = uc.Chrome(user_data_dir=basedir2,options=options)
mcoliver commented 1 year ago

The problem is the SingletonLock file. I submitted a PR for a fix here #1505 . Also be aware that if you use the substring 'headless' in your profile path, things will break. I submitted another PR #1506 to at least drop a warning about this but the logic for removing args that contain 'headless' should be updated.

joeld1 commented 11 months ago

I have the same issue on #1670

lynnwho12 commented 9 months ago

get the same issue on centos docker