Selenium-Injector icon indicating copy to clipboard operation
Selenium-Injector copied to clipboard

Proxy error

Open citizen-seven opened this issue 1 year ago • 14 comments

Describe the bug Locally on macbook the script runs well, but when I try to run it on a server, it fails with a "User not connected" error.

To Reproduce

from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium.webdriver import ChromeOptions
import time

options = ChromeOptions()

options.add_argument('--no-sandbox')
options.add_argument("--headless=new")

profile = profiles.Windows()
driver = Chrome(profile, uc_driver=False, options=options, injector_options=True)
driver.profiles.injector.proxy.set_single(host="172.67.254.243", port=80, username='user', password='12345')

input('finishing')
driver.quit()

Expected behavior or error-message Same behavior as on a local machine. Basically the code fails in selenium-injector when checking for the "current auth" state.

Traceback (most recent call last):
  File "/home/rishat/fail.py", line 14, in <module>
    driver.profiles.injector.proxy.set_single(host="172.67.254.243", port=80, username='user', password='12345')
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/injector.py", line 241, in set_single
    if self.auth:
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/injector.py", line 221, in auth
    return self.socket.exec(self.socket.js.types.path("proxy.credentials"),
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/socket.py", line 27, in exec
    result = self.post(json.dumps(script), user=user, timeout=timeout, start_time=start_time, interval=interval)
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/sync_websocket.py", line 109, in post
    self.send(message=parsed, user=user, timeout=timeout, start_time=start_time, interval=interval)
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/sync_websocket.py", line 96, in send
    user = self.wait_user(user, timeout=timeout, interval=interval, start_time=start_time)
  File "/home/rishat/vfs-test/lib/python3.10/site-packages/selenium_injector/scripts/sync_websocket.py", line 144, in wait_user
    raise TimeoutError("User not connected")
TimeoutError: User not connected

Environment (please complete the following information):

  • OS: Ubuntu
  • OS-Version 22.04.4 LTS
  • Browser Chrome 123.0.6312.58
  • Selenium-Profiles Version 2.2.10
  • Selenium Version 4.18.1
  • selenium-driverless Version 1.8.0.2
  • Python versin 3.10.12

Additional context

citizen-seven avatar Mar 24 '24 07:03 citizen-seven

socks5 ?

ttlns avatar Mar 24 '24 07:03 ttlns

Please @kaliiiiiiiiii what could be the cause of the error?, so we know how to avoid it. , sometimes i experience it, proxy is not socks5.


Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Administrator\Downloads\project_bot\main.py", line 561, in manual_organic_search
    driver = Chrome(profile, options=options,
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_profiles\webdriver.py", line 182, in __init__
    self.profiles.proxy.set_single(proxy["proxy"], bypass_list=proxy["bypass_list"])
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_profiles\scripts\proxy.py", line 63, in set_single
    self._injector.proxy.set_single(**proxy)
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\injector.py", line 241, in set_single
    if self.auth:
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\injector.py", line 221, in auth
    return self.socket.exec(self.socket.js.types.path("proxy.credentials"),
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\socket.py", line 27, in exec
    result = self.post(json.dumps(script), user=user, timeout=timeout, start_time=start_time, interval=interval)
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\sync_websocket.py", line 109, in post
    self.send(message=parsed, user=user, timeout=timeout, start_time=start_time, interval=interval)
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\sync_websocket.py", line 96, in send
    user = self.wait_user(user, timeout=timeout, interval=interval, start_time=start_time)
  File "C:\Users\Administrator\PycharmProjects\pythonProject\.venv\lib\site-packages\selenium_injector\scripts\sync_websocket.py", line 144, in wait_user
    raise TimeoutError("User not connected")
TimeoutError: User not connected ```

wealthr avatar Dec 11 '24 08:12 wealthr

could indicate that the chrome-extension has not been loaded in correctly. Could you check that?

ttlns avatar Dec 11 '24 08:12 ttlns

What extension do you mean?

wealthr avatar Dec 11 '24 19:12 wealthr

What extension do you mean?

Well it should automatically load in a chrome-extension => check that

ttlns avatar Dec 11 '24 20:12 ttlns

It only loads this chrome://version/ and stops there

wealthr avatar Dec 12 '24 07:12 wealthr

It only loads this chrome://version/ and stops there

Load in the browser, not as a page lol

ttlns avatar Dec 12 '24 10:12 ttlns

Sorry i don't understand what you meant "Well it should automatically load in a chrome-extension => check that", How do i check it?

wealthr avatar Dec 12 '24 12:12 wealthr

This mostly happens when you run it in multiple threads

wealthr avatar Dec 12 '24 17:12 wealthr

Sorry i don't understand what you meant "Well it should automatically load in a chrome-extension => check that", How do i check it?

Check if a chrome extension is installed on headfull

ttlns avatar Dec 12 '24 17:12 ttlns

Yea, there's Selenium-injector extensions installed

wealthr avatar Dec 13 '24 07:12 wealthr

Yea, there's Selenium-injector extensions installed

mhh could be some racing condition then - not absolutely sure. You might consider moving to https://github.com/kaliiiiiiiiii/Selenium-Driverles since this project does not receive regular maintaiance anymore.

ttlns avatar Dec 13 '24 08:12 ttlns

From the Traceback report i think it's being caused by Selenium-injector.

Is there anyway to emulate screen sizes and useragents in selenium driverless?.

wealthr avatar Dec 13 '24 08:12 wealthr

Is there anyway to emulate screen sizes and useragents in selenium driverless?.

Yes - but it's detectable anyways Just as selenium profiles

ttlns avatar Dec 13 '24 11:12 ttlns