Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
change to proxy.py to fix failing to connect to websocket errors (#439)
Browse files Browse the repository at this point in the history
* Update proxy.py

fix for "failed to connect to websocket" error

* nox
  • Loading branch information
deemfox authored Apr 4, 2022
1 parent 713c2c6 commit b82cebd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ def get_board(self, access_token_in):
requests.get(
msg["data"]["name"],
stream=True,
proxies=proxy.get_random_proxy(self, name=None),
proxies=proxy.get_random_proxy(
self, name=None
),
).content
)
),
Expand Down
11 changes: 7 additions & 4 deletions src/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def Init(self):
)
self.tor_ip = (
self.json_data["tor_ip"]
if "tor_ip" in self.json_data
and self.json_data["tor_ip"] is not None
if "tor_ip" in self.json_data and self.json_data["tor_ip"] is not None
else "127.0.0.1"
)

Expand Down Expand Up @@ -110,12 +109,16 @@ def get_proxies(self, proxies):
return proxies_list
return proxies_list

#name is the username of the worker and is used for personal proxies

# name is the username of the worker and is used for personal proxies
def get_random_proxy(self, name=None):
if not self.using_tor:
random_proxy = None
if name is not None:
if self.json_data["workers"][name]["personal_proxy"] is not None:
if (
"personal_proxy" in self.json_data["workers"][name]
and self.json_data["workers"][name]["personal_proxy"] is not None
):
proxy = self.json_data["workers"][name]["personal_proxy"]
return {"https": proxy, "http": proxy}
if self.proxies is not None:
Expand Down

0 comments on commit b82cebd

Please sign in to comment.