Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Moving bot causes disconnect #203

Open
Otixa opened this issue Sep 28, 2021 · 5 comments
Open

Moving bot causes disconnect #203

Otixa opened this issue Sep 28, 2021 · 5 comments
Labels
Bug Something isn't working Internal Somthing internal that needs to be changed TODO Somthing that is critical and needs to be done

Comments

@Otixa
Copy link

Otixa commented Sep 28, 2021

I've noticed that moving a barebones bot from one channel to the other seems to cause it to disconnect.
The bot only has a Ready event handler that finds the "General" voice channel and joins it.
After moving it to a different channel, the bot disconnects.
Any help and/or hints would be greatly appreciated.

Upon further inspection, I have found the following:

05:04:18 Audio #1    Heartbeat Stopped
05:04:18 Audio #1    Keepalive Stopped
05:04:18 Audio #1    System.Exception: WebSocket connection was closed
 ---> Discord.Net.WebSocketClosedException: The server sent close 4014: "Disconnected."
   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)
   --- End of inner exception stack trace ---
   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext()
05:04:18 Audio #1    Failed to start the connection: System.Exception: WebSocket connection was closed ---> Discord.Net.WebSocketClosedException: The server sent close 4014: "Disconnected."   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)   --- End of inner exception stack trace ---   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext():
System.Exception: WebSocket connection was closed
 ---> Discord.Net.WebSocketClosedException: The server sent close 4014: "Disconnected."
   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)
   --- End of inner exception stack trace ---
   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext()
05:04:18 Audio #1    Disconnecting
05:04:18 Audio #1    Disconnecting ApiClient
05:04:18 Audio #1    Waiting for heartbeater
05:04:18 Audio #1    Sending Voice State
05:04:18 Gateway     Sent VoiceStateUpdate
05:04:18 Audio #1    Disconnected
05:04:18 Audio #1    Failed to start the connection: System.Exception: WebSocket connection was closed ---> Discord.Net.WebSocketClosedException: The server sent close 4014: "Disconnected."   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)   --- End of inner exception stack trace ---   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext():
System.Exception: WebSocket connection was closed
 ---> Discord.Net.WebSocketClosedException: The server sent close 4014: "Disconnected."
   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)
   --- End of inner exception stack trace ---
   at Discord.ConnectionManager.<>c__DisplayClass29_0.<<StartAsync>b__0>d.MoveNext()
05:04:18 Gateway     Received Dispatch (VOICE_STATE_UPDATE)
@MrCakeSlayer MrCakeSlayer added the Bug Something isn't working label Sep 29, 2021
@emillly-b
Copy link
Contributor

Can you show the code that is calling this code? @Otixa

@quinchs
Copy link
Member

quinchs commented Oct 1, 2021

Can you show the code that is calling this code? @Otixa

I think his error happens when you drag the bot to another voice channel on discord, not particularly any code.

Upon further inspection, I have found the following:

What's weird is the bot should just reconnect the voice socket to the new channel. this shouldn't cause the main socket to die

@Otixa
Copy link
Author

Otixa commented Oct 3, 2021

I think his error happens when you drag the bot to another voice channel on discord, not particularly any code.

@quinchs is correct. It seems to be some issue deep down not related to any specific implementation code.

What's weird is the bot should just reconnect the voice socket to the new channel. this shouldn't cause the main socket to die

It is weird. I've tried doing it several different ways and always get the same result.

As an update, since creating the issue I've tried to replicate this in Discord.Net vanilla and it seems to be happening there as well.
DSharpPlus does not exhibit the same behavior.

@emillly-b
Copy link
Contributor

image

Exception is thrown by design in DefaultWebSocketClient

I've found a similar issue in another Discord lib: abalabahaha/eris#1178

@quinchs
Copy link
Member

quinchs commented Oct 12, 2021

This should be reworked to seamlessly allow switching between voice channels without disrupting the socket on the dev end.

@MrCakeSlayer MrCakeSlayer added Internal Somthing internal that needs to be changed TODO Somthing that is critical and needs to be done labels Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Internal Somthing internal that needs to be changed TODO Somthing that is critical and needs to be done
Projects
None yet
Development

No branches or pull requests

4 participants