Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old geckodriver releases raise an exception (code 64) if started with unsupported --websocket-port argument #1959

Closed
its-ogawa opened this issue Nov 15, 2021 · 22 comments
Labels

Comments

@its-ogawa
Copy link

System

  • Version: 0.26.0
  • Platform: CentOS 6.9
  • Firefox: 78.5.0esr
  • Selenium: 4.0.0

Testcase

geckodriver throws an exception (code 64).
What is the cause?

Also, is there a page with the code for the exception?

Any advice would be appreciated in advance.

# python scripts/like_sample.py
 ._.  ._.  ._.  ._.  ._.  ._.  ._.  ._.  ._.  ._.  ._.
No any custom workspace provided.       ~using existing..
InstaPy Version: 0.6.14
 ._.  ._.  ._.  ._.  ._.  ._.  ._.
Workspace in use: "/root/InstaPy"
Traceback (most recent call last):
  File "scripts/like_sample.py", line 21, in <module>
    session = InstaPy(username=USERNAME,
  File "/root/anaconda3/envs/ipy38/lib/python3.8/site-packages/instapy/instapy.py", line 327, in __init__
    self.browser, err_msg = set_selenium_local_session(
  File "/root/anaconda3/envs/ipy38/lib/python3.8/site-packages/instapy/browser.py", line 123, in set_selenium_local_session
    browser = webdriver.Firefox(
  File "/root/anaconda3/envs/ipy38/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 175, in __init__
    self.service.start()
  File "/root/anaconda3/envs/ipy38/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 101, in start
    self.assert_process_still_running()
  File "/root/anaconda3/envs/ipy38/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 113, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service /root/anaconda3/envs/ipy38/bin/geckodriver unexpectedly exited. Status code was: 64
@its-ogawa
Copy link
Author

When I changed the version of INAPPROPRIATEgeckodriver to the latest 0.29.1 obtained from the following, the Status code became 1.
https://anaconda.org/conda-forge/geckodriver/files

What action do I need to take?

# wget https://anaconda.org/conda-forge/geckodriver/0.29.1/download/linux-64/geckodriver-0.29.1-h3146498_0.tar.bz2
... snip ...
# conda install geckodriver-0.29.1-h3146498_0.tar.bz2
... snip ...

# python scripts/like_sample.py
... snip ...
.../geckodriver unexpectedly exited. Status code was: 1

@whimboo
Copy link
Collaborator

whimboo commented Nov 15, 2021

Please update to geckodriver 0.30.0, and try again. Further please provide trace logs of geckodriver. It may also help to upgrade Firefox to at least the latest 91 ESR release.

@its-ogawa
Copy link
Author

Before I knew it, 0.30.0 had been added!

I got 0.30.0 and confirmed that I don't get Exceptions.
Thank you very much.

The FireFox version is still the same.

Sadly, I got another CRITICAL error.
Maybe there is a problem with my account this time.

(ipy38) [root@<hostname> python]# python scripts/like_sample.py
 ._.  ._.  ._.  ._.  ._.  ._.  ._.  ._.
Custom workspace set: "/root/InstaPy" :]
InstaPy Version: 0.6.14
 ._.  ._.  ._.  ._.  ._.  ._.  ._.
Workspace in use: "/root/InstaPy"
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2021-11-15 19:10:04] [<username>]  Session started!
oooooooooooooooooooooooooooooooooooooooooooooooooooooo
INFO [2021-11-15 19:10:04] [<username>]  -- Connection Checklist [1/2] (Internet Connection Status)
INFO [2021-11-15 19:10:04] [<username>]  - Internet Connection Status: ok
INFO [2021-11-15 19:10:04] [<username>]  - Current IP is "2001:240:bb82:2300::1:1b" and it's from "Japan/JP"
INFO [2021-11-15 19:10:04] [<username>]  -- Connection Checklist [2/2] (Hide Selenium Extension)
INFO [2021-11-15 19:10:04] [<username>]  - window.navigator.webdriver response: None
INFO [2021-11-15 19:10:04] [<username>]  - Hide Selenium Extension: ok
INFO [2021-11-15 19:10:07] [<username>]  - Cookie file not found, creating cookie...
........................................................................................................................
CRITICAL [2021-11-15 19:10:47] [<username>]  Unable to login to Instagram! You will find more information in the logs above.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

INFO [2021-11-15 19:10:48] [<username>]  Sessional Live Report:
        |> No any statistics to show


[Session lasted 47.54 seconds]
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2021-11-15 19:10:48] [<username>]  Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooo

@whimboo
Copy link
Collaborator

whimboo commented Nov 15, 2021

Again, without a trace log there is nothing that we can actually help with in regards of the currently provided details. So please attach one. Thanks.

@its-ogawa
Copy link
Author

@whimboo

I'm sorry.
I was thinking that the above log was it.

How can I get the trace log?

I am running the following command, but it does not output any results after the first line.

(ipy38) [root@<hostname> python]# geckodriver --log trace
1637022710856   geckodriver     INFO    Listening on 127.0.0.1:4444

@whimboo
Copy link
Collaborator

whimboo commented Nov 16, 2021

Sure, that will be all that's written to stdout as long as no client connects to geckodriver and tries to create a session. You want to modify your original code so it starts geckodriver with that option or -vv. Then you will get all the trace log entries correctly printed out.

@its-ogawa
Copy link
Author

You will only get the following message
How can I get a log to track down the cause?

geckodriver -vv
1637051403715 geckodriver DEBUG Listening on 127.0.0.1:4444

@whimboo
Copy link
Collaborator

whimboo commented Nov 17, 2021

Is that with a client connecting to geckodriver? I doubt so. The client needs to send at least the new session command. You could use curl to do that. See the examples here:

https://firefox-source-docs.mozilla.org/testing/geckodriver/Usage.html#standalone

@ernstki
Copy link

ernstki commented Dec 29, 2021

@its-ogawa You are running a geckodriver older than 0.30.0, and it is missing the --websocket-port option, which newer/new-ish versions of Selenium seem to depend on.

I'm a bit frustrated by this, too, and I don't know what's the right answer. Nowhere in the Selenium documentation did I see anything stating "geckodriver 0.30.0 or higher is required." I feel like the selenium Python library should be trying harder to accommodate the older geckodrivers that are out there, for example, in Linux distros' official repositories or MacPorts. I mean the last release, 0.29.0, does not have the --websocket-port option, and it's not even that old—January 2021.

Here's how you can confirm:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

opts = Options()
opts.log.level = 'trace'

# source: https://firefox-source-docs.mozilla.org/testing/geckodriver/TraceLogs.html#python
# via: https://github.com/mozilla/geckodriver/issues/1959
browser = webdriver.Firefox(options=opts)

browser.get('https://github.com')

assert 'GitHub' in browser.title

Look at the contents of geckodriver.log in the current working directory and if you see

geckodriver: error: Found argument '--websocket-port' which wasn't expected, or isn't valid in this context

…then the version of geckodriver you have is too old for the version of Selenium you have.

As a workaround, try downloading a binary of 0.30.0 for your platform and make sure it shows up first in your shell's search path (putting it ~/bin should be fine), then run your tests again.

@its-ogawa
Copy link
Author

Binary download is a very good idea.
I've checked that too.
However, it is now possible to install 0.30.0 using anaconda as well.

@yacov-ma
Copy link

yacov-ma commented Dec 29, 2021

Hi,
I'm running on mac version Monterey 12.1

and getting the error as well.

attached trace log:
====== WebDriver manager ======
Driver [<>/geckodriver] found in cache
Traceback (most recent call last):
File "<>", line 12, in
return webdriver.Firefox(executable_path=GeckoDriverManager(version='v0.30.0').install())
File "<>/venv/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in init
self.service.start()
File "<>/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "<>/PycharmProjects/webDriverManagerDemo/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service <>/.wdm/drivers/geckodriver/macos/v0.30.0/geckodriver unexpectedly exited. Status code was: 64

In addition:
I've checked that the selenium and gecko version compatible according to https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html

@ernstki
Copy link

ernstki commented Dec 29, 2021

@yacov-ma Please follow the instructions above to have geckodriver write its own error log. From the contents of the geckodriver.log file, you should be able to determine why geckodriver "unexpectedly exited."

The status code returned to Selenium (64) may be the same, but the underlying problem could be different. Inspecting geckodriver.log is how you ascertain that.

@yacov-ma
Copy link

@ernstki Thank you for the quick reply.

This was actually the issue.
meanwhile, I'm using the workaround, any idea when they release a new version that fixes it?

@whimboo whimboo changed the title geckodriver raises an exception (code 64) Old geckodriver releases raise an exception (code 64) if started with unsupported --websocket-port argument Jan 3, 2022
@whimboo
Copy link
Collaborator

whimboo commented Jan 3, 2022

Thanks everyone for the feedback. As it has been manifested the problem here is not geckodriver but Selenium. As such you should create an issue on the Selenium repository instead, so that an option could be added to not always pass the --websocket-port argument. If that request gets denied you will have to use older releases of Selenium if testing with older geckodriver releases is really needed.

@ernstki
Copy link

ernstki commented Jan 3, 2022

This was actually the issue. meanwhile, I'm using the workaround, any idea when they release a new version that fixes it?

@yacov-ma Unless there is some obstacle in your environment preventing you from doing so, I would recommend just downloading a newer geckodriver binary from the releases page, and putting that somewhere in your search path.

This is beyond the scope of this issue, but if you are doing Selenium testing as one specific user, then ~/bin is the obvious choice for Mac and Linux. On Windows, you can drop the binary in C:\Windows\System32 for a quick-and-dirty solution. This blog post explains the steps for adding an arbitrary directory to the search path on all three platforms.

Just on principle, I'd like to see Selenium "fixed" to support geckodriver <0.30, but it's not something I'm going to invest time in when there's a quick workaround that works fine for my testing environment.

@whimboo
Copy link
Collaborator

whimboo commented Jan 4, 2022

Note that the support for older geckodriver releases highly depend on the Selenium binding that you are using. In case for Python it works still fine for geckodriver releases before 0.30.0. So which bindings are you using?

@Rabelaiss
Copy link

I'm trying to connect to an existing Firefox instance using selenium in python.
Versions:
Firefox 100.0.1 (64 bit)
selenium 4.1.3
python 3.10.1
geckodriver 0.31.0 (it is contained in the python folder, i.e. it is in PATH)
First I open the Firefox instance in cmd with the command

"C:\Program Files\Mozilla Firefox\firefox.exe" --start-debugger-server --profile C:\FirefoxTEMP

Then on python I run the following commands

from selenium import webdriver

option = webdriver.FirefoxOptions()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Firefox(options=options)

but get an error on the last line

~\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\webdriver.py in __init__(self, firefox_profile, firefox_binary, capabilities, proxy, executable_path, options, service_log_path, service_args, service, desired_capabilities, log_path, keep_alive)
    145         # options overrides capabilities
    146         if options:
--> 147             if options.binary:
    148                 self.binary = options.binary
    149             if options.profile:

AttributeError: 'Options' object has no attribute 'binary'

What am I doing wrong? Is there a solution? Thanks

@whimboo
Copy link
Collaborator

whimboo commented May 23, 2022

@Rabelaiss your question is not related to this issue at all, and which is also closed.

Also this question seems to be more related to Selenium than geckodriver. I would suggest to ask over there.

@Rabelaiss
Copy link

Rabelaiss commented May 23, 2022

@whimboo Pardon me, I thought it was related since I was redirected here from another question #1980 where an user was trying to connect to an existing instance of Firefox with Selenium

@JianquanZhao
Copy link

When I changed the version of INAPPROPRIATEgeckodriver to the latest 0.29.1 obtained from the following, the Status code became 1. https://anaconda.org/conda-forge/geckodriver/files

What action do I need to take?

# wget https://anaconda.org/conda-forge/geckodriver/0.29.1/download/linux-64/geckodriver-0.29.1-h3146498_0.tar.bz2
... snip ...
# conda install geckodriver-0.29.1-h3146498_0.tar.bz2
... snip ...

# python scripts/like_sample.py
... snip ...
.../geckodriver unexpectedly exited. Status code was: 1

specify the path of the geckodriver may fix this error in the follow way:
options = Options()
options.add_argument("--headless")
options.binary_location='./firefox/firefox'
options.add_argument('--headless')
driver = webdriver.Firefox(service=Service('./geckodriver'),options=options)

@whimboo
Copy link
Collaborator

whimboo commented Dec 19, 2023

As per our support table for geckodriver the 0.29.1 version can only be used up to Firefox 90. And this is most likely not what you want given that support for this Firefox version ended ages ago.

@its-ogawa
Copy link
Author

@whimboo
Thanks for letting me know about Supported platforms.
The reason I asked the question is because I wanted to use a Python library that required geckodriver as a WebDriver back then, 2 years ago.
I haven't tried it recently, but would like to try it with the latest geckodriver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants