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

Dirty cache in websocket.py when reconnect to network #242

Open
duffy356 opened this issue Nov 22, 2021 · 3 comments
Open

Dirty cache in websocket.py when reconnect to network #242

duffy356 opened this issue Nov 22, 2021 · 3 comments
Assignees
Labels
2.0 TwitchIO 2.0 bug IRC IRC related items.

Comments

@duffy356
Copy link

I have encountered an issue with reconnects or changes of the network while running the bot.

When the network connection is dead for less than one minute, the cached connections from the websocket may still work, but when the network is offline for more than 5 minutes, then the websocket will reconnect, but the previous connections from the websocket._cache dictionary are outdated and dead. The Library will not connect automatically to the previously connected channels.

I could fix it for my concrete usage with an overloaded version of the following method in Client's subclass:

async def event_ready(self):
    # We are logged in and ready to chat and use commands...
    self._logger.info(f'Logged in on Twitch as | {self.nick}')
    if len(self._connection._cache) > 1:
        keys_to_delete = []
        for key in self._connection._cache.keys():
            if key != "duffy356":
                self._logger.info(f"logged in with {key} in cache")
                keys_to_delete.append(key)

        for key in keys_to_delete:
            del self._connection._cache[key]
        self._logger.info(f"removed all users from cache that were outdated!")

It would be nice to automatically reconnect to the connected channels from the websocket's cache or at least remove the entries from the cache, so that a new call of join_channels("a") will allow the library to make a new connection to channel "a".

@IAmTomahawkx IAmTomahawkx added 2.0 TwitchIO 2.0 bug IRC IRC related items. labels Feb 17, 2022
@gitagogaming
Copy link

I assume this has not been resolved? I do believe this is an issue I'm encountered now..

when my PC is put to sleep for more than a few minutes then when coming back online the chatbot is no longer connected.. although some parts of it do seem to still be active which is a bit odd.

@alkim0
Copy link

alkim0 commented Apr 4, 2023

Just to verify, #364 does not resolve this, correct?

EDIT: It does not.

@Nevrai
Copy link

Nevrai commented Jun 18, 2023

I’m having the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 TwitchIO 2.0 bug IRC IRC related items.
Projects
None yet
Development

No branches or pull requests

6 participants