diff --git a/lavalink/WebSocket.py b/lavalink/WebSocket.py index d014bca7..18256bc9 100644 --- a/lavalink/WebSocket.py +++ b/lavalink/WebSocket.py @@ -55,11 +55,21 @@ async def connect(self): else: log.info('Connected to Lavalink!') self._loop.create_task(self.listen()) + self._loop.create_task(self._keep_alive()) if self._queue: log.info('Replaying %d queued events...', len(self._queue)) for task in self._queue: await self.send(**task) + async def _keep_alive(self): + """ + Sends a ping to the Lavalink server every 2 seconds + Experimental fix to attempt to solve issues where nothing is sent via the websocket after a certain amount of time + """ + while self._shutdown is False: + await self._ws.ping() + await asyncio.sleep(2) + async def _attempt_reconnect(self) -> bool: """ Attempts to reconnect to the lavalink server. diff --git a/lavalink/__init__.py b/lavalink/__init__.py index 7dfeefb1..5a645394 100644 --- a/lavalink/__init__.py +++ b/lavalink/__init__.py @@ -2,7 +2,7 @@ __author__ = 'Luke & William' __license__ = 'MIT' __copyright__ = 'Copyright 2018 Luke & William' -__version__ = '2.1.5' +__version__ = '2.1.6' from .AudioTrack import * from .Client import * diff --git a/setup.py b/setup.py index 11c71d90..c867f7dd 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,12 @@ setup( name='lavalink', packages=['lavalink'], - version='2.1.5', + version='2.1.6', description='A lavalink interface built for discord.py', author='Luke, William', - author_email='dev@crimsonxv.pro', + author_email='luke@serux.pro', url='https://github.com/Devoxin/Lavalink.py', - download_url='https://github.com/Devoxin/Lavalink.py/archive/2.1.5.tar.gz', + download_url='https://github.com/Devoxin/Lavalink.py/archive/2.1.6.tar.gz', keywords=['lavalink'], include_package_data=True, install_requires=['websockets>=4.0.0,<5.0.0', 'aiohttp']