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

[V3 Audio] Unable to set external lavalink #2306

Closed
mikeshardmind opened this issue Nov 21, 2018 · 3 comments · Fixed by #2335
Closed

[V3 Audio] Unable to set external lavalink #2306

mikeshardmind opened this issue Nov 21, 2018 · 3 comments · Fixed by #2335
Labels
Status: Accepted We want this Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

Comments

@mikeshardmind
Copy link
Contributor

Right now, audio can't be loaded if lavalink can't be started. If the reason it can't be started is the port is already in use by another instance or by something completely unrelated, then the cog can't be configured to use an external lavalink server, and thus gets locked in an inability to load it.

I think the best method to fix this would be to load the cog even without the lavalink server, but place a check on commands that need lavalink that blocks them if there is no lavalink server connection. This would allow remedying this without having to interfere with other running processes, shut down other instances, or manually modify configuration files.

@calebj
Copy link
Member

calebj commented Nov 23, 2018

👍 for this. I have a fix that enables the external connection based on environmental variable in my docker-compose setup, but an update that allows the cog to load and attempt init/connect in the background would be more ideal.

calebj added a commit to calebj/Red-DiscordBot that referenced this issue Dec 17, 2018
Also:
- restart and reconnect if connection settings change
  - shutdown and restart if not configured to use external
- show a message in [p]play et al. when the connection hasn't been made
- move the JAR download to manager so audio.py can access it
- only start if no process exists

Resolves Cog-Creators#2306
@Tobotimus Tobotimus added Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. V3 Status: Accepted We want this labels Dec 21, 2018
@Tobotimus Tobotimus added Status: In Progress There's a PR open to deal with this, or an org member is working on this internally and removed Status: Accepted We want this labels Feb 16, 2019
Tobotimus pushed a commit that referenced this issue Feb 16, 2019
Also:
- restart and reconnect if connection settings change
  - shutdown and restart if not configured to use external
- show a message in [p]play et al. when the connection hasn't been made
- move the JAR download to manager so audio.py can access it
- only start if no process exists

Resolves #2306
@Tobotimus Tobotimus removed the Status: In Progress There's a PR open to deal with this, or an org member is working on this internally label Feb 16, 2019
@Tobotimus Tobotimus reopened this Feb 16, 2019
@Tobotimus Tobotimus added the Status: Accepted We want this label Feb 16, 2019
@aikaterna
Copy link
Member

aikaterna commented Feb 16, 2019

I've been speaking with Caleb in DMs about #2335, but on Windows computers the IndexErrors added in Audio to catch a missing Lavalink server are not firing, resulting in a traceback.

[04/02/2019 21:27] ERROR events on_command_error 208: Exception in command 'play'
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 822, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
  File "c:\program files\python37\lib\asyncio\base_events.py", line 943, in create_connection
    raise exceptions[0]
  File "c:\program files\python37\lib\asyncio\base_events.py", line 930, in create_connection
    await self.sock_connect(sock, address)
  File "c:\program files\python37\lib\asyncio\proactor_events.py", line 545, in sock_connect
    return await self._proactor.connect(sock, address)
  File "c:\program files\python37\lib\asyncio\windows_events.py", line 732, in _poll
    value = callback(transferred, key, ov)
  File "c:\program files\python37\lib\asyncio\windows_events.py", line 524, in finish_connect
    ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

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

Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\program files\python37\lib\site-packages\redbot\cogs\audio\audio.py", line 960, in play
    tracks = await player.get_tracks(query)
  File "c:\program files\python37\lib\site-packages\lavalink\rest_api.py", line 155, in get_tracks
    async with self._session.get(url, headers=self._headers) as resp:
  File "c:\program files\python37\lib\site-packages\aiohttp\client.py", line 855, in __aenter__
    self._resp = await self._coro
  File "c:\program files\python37\lib\site-packages\aiohttp\client.py", line 370, in _request
    timeout=timeout
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 445, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 757, in _create_connection
    req, traces, timeout)
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 879, in _create_direct_connection
    raise last_exc
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 862, in _create_direct_connection
    req=req, client_error=client_error)
  File "c:\program files\python37\lib\site-packages\aiohttp\connector.py", line 829, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:2333 ssl:None [The remote computer refused the network connection]

@calebj
Copy link
Member

calebj commented Feb 16, 2019

@aikaterna can you verify Red-Lavalink 0.2.2 is installed? I pushed a commit that fixed a return type for one of the check functions, but I might have to open another PR for it.

Tobotimus pushed a commit that referenced this issue Feb 16, 2019
Also:
- restart and reconnect if connection settings change
  - shutdown and restart if not configured to use external
- show a message in [p]play et al. when the connection hasn't been made
- move the JAR download to manager so audio.py can access it
- only start if no process exists
- bump red-lavalink to 0.2.3

Resolves #2306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted We want this Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants