gologinapp / pygologin

REST API provides programmatic access to GoLogin App. Create a new browser profile, get a list of all browser profiles, add a browser profile and running
Other
66 stars 43 forks source link

Headless doesn't work #30

Open nisnevich opened 1 year ago

nisnevich commented 1 year ago

Gologin works perfectly fine non-headless, but whenever I add --headless, chromedriver just fails to connect with error: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:3500

Even though I see that the debugger is up:

[satoshi@satoshi-hpnotebook ~]$ lsof -i:3500 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME chrome 11621 satoshi 49u IPv4 172737 0t0 TCP localhost:rtmp-port (LISTEN)

And when running the script, I see in logs that debugger actually starts listening:

DevTools listening on ws://127.0.0.1:3500/devtools/browser/1747b39d-524b-496f-8c83-bb260953aa3b

The versions of the browser and chromedriver are 100% compatible:

[satoshi@satoshi-hpnotebook ~]$ /home/satoshi/.gologin/browser/orbita-browser-110/chrome --version Orbita 110.0.5481.77 [satoshi@satoshi-hpnotebook ~]$ chromedriver --version ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839})

Here's a sample code that recreates the issue:

from gologinpy.gologin import GoLogin
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

gl = GoLogin(
    {
        "token": "your_token",
        'profile_id': '642ef47fbb17687a5f4084df',
        'extra_params': ['--headless'],
    }
)

print("Starting Gologin...")
debugger_address = gl.start()

# Create browser options
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)

print("Starting Selenium webdriver...")
print("Connecting to ", debugger_address)
# Start Selenium
webdriver.Chrome(
    options=chrome_options,
)

print("Opening page...")
driver.get(f"https://www.google.com/")

OS: Linux 5.10.167-1-MANJARO x86_64 GNU/Linux

sujaykhandekar commented 1 year ago

hey were you able to make gologin work in headless mode? I also have similar requirements, i think if headless is not supported, maybe you can use xvfb-run with your scripts which will basically run with virtual display and emulate the headed behavior. Not sure if it can work with goLogin browser though.

iiezhachenko commented 6 months ago

I managed to make it work. Here I posted how to update your profiles Orbita: https://github.com/gologinapp/pygologin/issues/88

When you did that, you --headless=new instead of --headless

stepjet commented 6 months ago

@sujaykhandekar could you try to update orbita to latest version?

stepjet commented 6 months ago

@sujaykhandekar btw, also you can run headfull browser with xvfb, here is the guide https://github.com/gologinapp/gologin-vnc-guide