Cog-Creators/Red-Lavalink

[Lavalink V3] Not restarting rest session

TheWyn opened this issue · 4 comments

Type:

  • Suggestion
  • Bug

Brief description of the problem

When discord has a hiccup, lavalink still thinks the same session is up and tries to act normally. Instead when attempting to play a song, Red reports back the song is running after thinking it connected to the voice channel. Stop commands still work as shown below. When using the [p]disconnect command is issued then the play command, Red gives the session is closed trace. Restarting the machine fixes the issue. Restarting Red, Audio cog or Lavalink jar separately does not fix the issue.


Apr 17 20:23:52 arch python3.6[389]: Attempting a reconnect in 1.79s
Apr 17 20:23:52 arch python3.6[389]: Traceback (most recent call last):
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/connector.py", line 378, in connect
Apr 17 20:23:52 arch python3.6[389]:     proto = yield from self._create_connection(req)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/connector.py", line 687, in _create_connection
Apr 17 20:23:52 arch python3.6[389]:     _, proto = yield from self._create_direct_connection(req)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/connector.py", line 698, in _create_direct_connection
Apr 17 20:23:52 arch python3.6[389]:     hosts = yield from self._resolve_host(req.url.raw_host, req.port)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/connector.py", line 669, in _resolve_host
Apr 17 20:23:52 arch python3.6[389]:     self._resolver.resolve(host, port, family=self._family)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/resolver.py", line 31, in resolve
Apr 17 20:23:52 arch python3.6[389]:     host, port, type=socket.SOCK_STREAM, family=family)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Apr 17 20:23:52 arch python3.6[389]:     result = self.fn(*self.args, **self.kwargs)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
Apr 17 20:23:52 arch python3.6[389]:     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
Apr 17 20:23:52 arch python3.6[389]: socket.gaierror: [Errno -3] Temporary failure in name resolution
Apr 17 20:23:52 arch python3.6[389]: The above exception was the direct cause of the following exception:
Apr 17 20:23:52 arch python3.6[389]: Traceback (most recent call last):
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/client.py", line 408, in connect
Apr 17 20:23:52 arch python3.6[389]:     yield from self._connect()
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/shard.py", line 286, in _connect
Apr 17 20:23:52 arch python3.6[389]:     f.result()
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/shard.py", line 84, in poll
Apr 17 20:23:52 arch python3.6[389]:     self.ws = yield from asyncio.wait_for(coro, timeout=180.0, loop=self.loop)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
Apr 17 20:23:52 arch python3.6[389]:     return fut.result()
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/gateway.py", line 199, in from_client
Apr 17 20:23:52 arch python3.6[389]:     gateway = yield from client.http.get_gateway()
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/http.py", line 754, in get_gateway
Apr 17 20:23:52 arch python3.6[389]:     data = yield from self.request(Route('GET', '/gateway'))
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/http.py", line 156, in request
Apr 17 20:23:52 arch python3.6[389]:     r = yield from self._session.request(method, url, **kwargs)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/helpers.py", line 97, in __iter__
Apr 17 20:23:52 arch python3.6[389]:     ret = yield from self._coro
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 231, in _request
Apr 17 20:23:52 arch python3.6[389]:     conn = yield from self._connector.connect(req)
Apr 17 20:23:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/connector.py", line 383, in connect
Apr 17 20:23:52 arch python3.6[389]:     .format(key, exc.strerror)) from exc
Apr 17 20:23:52 arch python3.6[389]: aiohttp.client_exceptions.ClientConnectorError: [Errno -3] Cannot connect to host discordapp.com:443 ssl:T>
Apr 17 21:21:59 arch python3.6[389]: [17/04/2018 21:21] ERROR events on_command_error 198: Exception in command 'play'
Apr 17 21:21:59 arch python3.6[389]: Traceback (most recent call last):
Apr 17 21:21:59 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/ext/commands/core.py", line 62, in wrapped
Apr 17 21:21:59 arch python3.6[389]:     ret = yield from coro(*args, **kwargs)
Apr 17 21:21:59 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/redbot/cogs/audio/audio.py", line 499, in play
Apr 17 21:21:59 arch python3.6[389]:     tracks = await player.get_tracks(query)
Apr 17 21:21:59 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/lavalink/rest_api.py", line 74, in get_tracks
Apr 17 21:21:59 arch python3.6[389]:     async with self._session.get(url, headers=self._headers) as resp:
Apr 17 21:21:59 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 603, in __aenter__
Apr 17 21:21:59 arch python3.6[389]:     self._resp = yield from self._coro
Apr 17 21:21:59 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 168, in _request
Apr 17 21:21:59 arch python3.6[389]:     raise RuntimeError('Session is closed')
Apr 17 21:21:59 arch python3.6[389]: RuntimeError: Session is closed
Apr 17 22:12:52 arch python3.6[389]: [17/04/2018 22:12] ERROR events on_command_error 198: Exception in command 'play'
Apr 17 22:12:52 arch python3.6[389]: Traceback (most recent call last):
Apr 17 22:12:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/discord/ext/commands/core.py", line 62, in wrapped
Apr 17 22:12:52 arch python3.6[389]:     ret = yield from coro(*args, **kwargs)
Apr 17 22:12:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/redbot/cogs/audio/audio.py", line 499, in play
Apr 17 22:12:52 arch python3.6[389]:     tracks = await player.get_tracks(query)
Apr 17 22:12:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/lavalink/rest_api.py", line 74, in get_tracks
Apr 17 22:12:52 arch python3.6[389]:     async with self._session.get(url, headers=self._headers) as resp:
Apr 17 22:12:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 603, in __aenter__
Apr 17 22:12:52 arch python3.6[389]:     self._resp = yield from self._coro
Apr 17 22:12:52 arch python3.6[389]:   File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 168, in _request
Apr 17 22:12:52 arch python3.6[389]:     raise RuntimeError('Session is closed')
Apr 17 22:12:52 arch python3.6[389]: RuntimeError: Session is closed


Expected behavior

Restart the session if needed (or when discord is having problems).

Screenshot, as you can see while Red reports back it's playing Rip & Tear, but Red never actually connects to a voice channel, The play command trace is posted above: bug

Got the same issue, but at a random moment.

Itd be nice if it restarted the session or a way to restart it manually, I have this issue when I edit my firewall rules it closes the session

I am also seem to be getting the same issue, albeit, once a week or two, and only bot restart or OS reboot seems to fix it.
I am hosting my redbot instance (V3 RC2) on Google cloud, on Ubuntu 18.04 LTS release. python3 version is 3.6.7
I have discussed this with aika an hour ago and aika suggested me to add this here.

Traceback (most recent call last):
  File "/home/flux/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 61, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/flux/.local/lib/python3.6/site-packages/redbot/cogs/audio/audio.py", line 1044, in play
    await self._enqueue_tracks(ctx, query)
  File "/home/flux/.local/lib/python3.6/site-packages/redbot/cogs/audio/audio.py", line 1050, in _enqueue_tracks
    tracks = await player.get_tracks(query)
  File "/home/flux/.local/lib/python3.6/site-packages/lavalink/rest_api.py", line 82, in get_tracks
    async with self._session.get(url, headers=self._headers) as resp:
  File "/home/flux/.local/lib/python3.6/site-packages/aiohttp/client.py", line 855, in __aenter__
    self._resp = await self._coro
  File "/home/flux/.local/lib/python3.6/site-packages/aiohttp/client.py", line 254, in _request
    raise RuntimeError('Session is closed')
RuntimeError: Session is closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/flux/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 898, in invoke
    await ctx.command.invoke(ctx)
  File "/home/flux/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 614, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/flux/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 70, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: Session is closed