I'm able to run a script on linux but on that same machine, if apache runs the script, I get TimeoutException. Message: connection refused
Looking into geckodriver.log, it says:
1604976847149 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilehZbDYR"
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Running without a11y support!
*** You are running in headless mode.
I think this part is just a warning - not an error? I'm not sure.
To start Firefox, I'm basically doing this: https://github.com/timgrossmann/InstaPy/blob/master/instapy/browser.py
Which doesn't use XVFB or any virtual display, just "-headless" and the Firefox extension.
Any idea why this code would run flawless on command line but not if it's called from apache?
Here's the full trace:
TimeoutException: Message: connection refused
File "django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "mainapp/views.py", line 277, in api
send_message(message, recipient_username)
File "scripts/browser_login.py", line 434, in send_message
driver = browser_login(username, password)
File "scripts/browser_login.py", line 123, in browser_login
options=firefox_options,
File "selenium/webdriver/firefox/webdriver.py", line 162, in __init__
keep_alive=True)
File "selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
This happens exactly 60 seconds after starting the script. It sits on the webdriver initialization.