eriknyquist / nedry

Nedry is a fun & useful discord bot with a modular plugin system (formerly "twitch_monitor_discord_bot")
Apache License 2.0
10 stars 4 forks source link

Twitch streamer annoucenemts stop working sometimes #5

Closed rkantos closed 1 year ago

rkantos commented 1 year ago

This is not the full trace but should be enough. Restarting Nedry fixes this issue. I guess some error would need to be catched?

Twitch userids changed to 00000000

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f8e41f26490>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twitch.tv', port=443): Max retries exceeded with url: /helix/streams?user_id=00000000 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8e41f26490>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 156, in _streamer_check_loop
    self._check_streamers_retry()
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 131, in _check_streamers_retry
    self._check_streamers()
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 91, in _check_streamers
    channels = self.read_all_streamer_info()
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 196, in read_all_streamer_info
    all_info = [self._read_streamer_info(u) for u in self.usernames]
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 196, in <listcomp>
    all_info = [self._read_streamer_info(u) for u in self.usernames]
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 186, in _read_streamer_info
    return TwitchChannel(user, username)
  File "/usr/local/lib/python3.9/dist-packages/nedry/twitch_monitor.py", line 34, in __init__
    self.is_live = False if user is None else user.is_live
  File "/home/csgo/.local/lib/python3.9/site-packages/twitch/helix/models/user.py", line 39, in is_live
    if self.stream:
  File "/home/csgo/.local/lib/python3.9/site-packages/twitch/helix/models/user.py", line 34, in stream
    return helix.Streams(api=self._api, user_id=int(self.id))[0]
  File "/home/csgo/.local/lib/python3.9/site-packages/twitch/helix/resources/streams.py", line 17, in __init__
    response: dict = self._api.get(self._path, params=kwargs)
  File "/home/csgo/.local/lib/python3.9/site-packages/twitch/api.py", line 111, in get
    return self.request('GET', path, ignore_cache, params=params, headers=self._headers(headers), **kwargs)
  File "/home/csgo/.local/lib/python3.9/site-packages/twitch/api.py", line 90, in request
    response = requests.Session().send(request)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.twitch.tv', port=443): Max retries exceeded with url: /helix/streams?user_id=00000000 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8e41f26490>: Failed to establish a new connection: [Errno 110] Connection timed out'))
eriknyquist commented 1 year ago

thanks, appreciate the traceback. I've experienced this one myself too. Will look into it.

eriknyquist commented 1 year ago

@rkantos would you mind sharing the "poll_period_seconds" value from your config file?

eriknyquist commented 1 year ago

I've pushed a possible fix for this issue to master, but I'm waiting for my test bot to hit the issue and confirm that it works, before I release a new version. Been running for a few days now without encountering the issue so just need to wait.

eriknyquist commented 1 year ago

No response from OP, and should be fixed in latest release, closing