Borgli / Ohminator

Repository for the Discord bot Ohminator
http://www.ohminator.com
Apache License 2.0
4 stars 0 forks source link

The audio of the bot sometimes is non-funtional #16

Closed Borgli closed 6 years ago

Borgli commented 6 years ago

At seemingly random times, the bot will lose audio functionality on one or several servers. The bot might have lost audio funtionality in one server, but not another. It's sporadic and, without tests, very hard to find the cause. Currently, the only fix is to restart the bot. I suspect that the reason could be a deadlock considering the nature of the bug.

Borgli commented 6 years ago

It seems 3289825 has fixed this issue. Will reopen if issue persists.

Borgli commented 6 years ago

This issue persists. We will probably only figure out the reason by doing extensive testing. Connected to issue #15.

Borgli commented 6 years ago

This is becoming an increasing issue. It affects both intros and youtube. In one case the youtube song would abrupty stop playing and the audio would be non-functional after that. This happened after just restarting the bot. A solution must be found soon. Either through testing or through trying to detect when it happens. The final solution would be to rewrite all the audio-capabilities. If that doesn't work, I will have to consider changing the Discord library.

Borgli commented 6 years ago

It has been several days of functioning audio after commit 24337d3. The commit is designed to catch the root of the issue, but it seems removing the update database function has lowered the error rate.

I can't imagine it not happening again, so will keep this issue open for now.

Borgli commented 6 years ago

The issue should be fixed in commit 045d451, and can be closed.

The issue can be reproduced by changing the server region to a different server. It is apparent that the reason for the bug is that the datastructure only updates when the voice_client object is created. This is a problem when the endpoint changes for example due to changing the server region, as the websocket will continue to send to the old endpoint, making the audio non-functional.

The solution is to disconnect and reconnect, but this is an annoying solution as it triggers the disconnect/connect sounds in Discord. I've therefore made a middleground in only using disconnect/connect when the bot is changing the channel, as this would trigger the sounds anyway. I've also added a command which can be used to disconnect the bot, forcing a reconnect.

The optimal solution would be for the library to give events or polling functions to react to endpoint-changes.