Skip to content

Commit

Permalink
Experimental fix for WS not sending after a while
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Jun 17, 2018
1 parent a259a1f commit 8c231ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lavalink/WebSocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lavalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 8c231ee

Please sign in to comment.