Skip to content
New issue

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

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

Already on GitHub? # to your account

[websocket] ERROR: [Errno 111] Connection refused - goodbye #210

Open
jfzlma opened this issue Dec 10, 2024 · 8 comments
Open

[websocket] ERROR: [Errno 111] Connection refused - goodbye #210

jfzlma opened this issue Dec 10, 2024 · 8 comments

Comments

@jfzlma
Copy link

jfzlma commented Dec 10, 2024

I am encountering the following error message when calling: driver.google_get("https://daftar-hitam.inaproc.id/", bypass_cloudflare=True)

code:
I am using botasaurus with Scrapy and running the crawler in Scrapyd. Below is the relevant code snippet:

from botasaurus.browser import browser, Driver
from pyvirtualdisplay import Display
display = Display(visible=1, size=(1920, 1080), backend="xvfb")
display.start()
driver = Driver()
driver.google_get("https://daftar-hitam.inaproc.id/", bypass_cloudflare=True)
cookies = driver.get_cookies()

I also tried using the @browser decorator, but I still get the same response.

Here is the error log I receive:

2024-12-10 05:43:53 [websocket] INFO: Websocket connected
2024-12-10 05:43:54 [websocket] ERROR: Connection to remote host was lost. - goodbye
2024-12-10 05:43:54 [websocket] ERROR: [Errno 111] Connection refused - goodbye
2024-12-10 05:43:54 [websocket] ERROR: [Errno 111] Connection refused - goodbye
2024-12-10 05:43:54 [websocket] ERROR: [Errno 111] Connection refused - goodbye
2024-12-10 05:43:54 [websocket] ERROR: [Errno 111] Connection refused - goodbye
@sonupandey228
Copy link

I am also getting same error. Tried to run in WSL environment.
image

@AntonioRubioMenchero
Copy link

i have the same error running in a docker container

@Ehsan-U
Copy link

Ehsan-U commented Jan 15, 2025

Same error

@aKob93
Copy link

aKob93 commented Jan 16, 2025

As far as I understood, when the browser is closed, the WebSocket connection remains open. I’m not sure why this was implemented or if I fully grasp the intended logic. However, adding the following line:

self.connection.close()

in the .../botasaurus_driver/core/browser.py module, specifically in the close_chrome() function, helped solve the issue for me.

Image

@Ehsan-U
Copy link

Ehsan-U commented Jan 17, 2025

@aKob93 close_browser_connection already doing this!

Image

@aKob93
Copy link

aKob93 commented Jan 17, 2025

@Ehsan-U
Since close_chrome() assigns self.connection = None, the condition if self.connection: in the subsequent close_browser_connection() function is never met, and thus the connection (self.connection.close()) is not closed.

One option is to remove or comment out the line self.connection = None in close_chrome(). This way, the if self.connection: condition in close_browser_connection() will be satisfied, allowing the connection to be properly closed.

@Ehsan-U
Copy link

Ehsan-U commented Jan 18, 2025

@aKob93 Thanks!
I have made the change but still getting the same error.

Image

@musaspacecadet
Copy link

@Ehsan-U self.connection = None is the issue, comment that out

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

No branches or pull requests

6 participants