Discord.Net-Labs
Discord.Net-Labs copied to clipboard
Moving bot causes disconnect
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)
Can you show the code that is calling this code? @Otixa
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
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.
Exception is thrown by design in DefaultWebSocketClient
I've found a similar issue in another Discord lib: https://github.com/abalabahaha/eris/pull/1178
This should be reworked to seamlessly allow switching between voice channels without disrupting the socket on the dev end.