How to use the twitchio.errors.WSConnectionFailure function in twitchio

To help you get started, we’ve selected a few twitchio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwitchIO / TwitchIO / twitchio / websocket.py View on Github external
async def connect(self):
        try:
            self._websocket = await websockets.connect('wss://pubsub-edge.twitch.tv')
        except Exception as e:
            self._last_result = e
            log.error('PubSub websocket connection failed | %s', e)

            raise WSConnectionFailure('PubSub websocket connection failed. Check logs for details.')

        log.info('PubSub %s connection successful', self.node)
        self._listener = self.loop.create_task(self.listen())
github TwitchIO / TwitchIO / twitchio / websocket.py View on Github external
async def delegate(self, *topics):
        for x in self.connections.values():
            if len(x._topics) == 50:
                continue
            elif len(x._topics) + len(topics) > 50:
                continue

            if x._websocket:
                return x

            await x.connect()

            if x._websocket.open:
                return x

            raise WSConnectionFailure('Unable to delegate WebSocket. Please try again.')
        raise ClientError('Maximum PubSub connections established.')