DPP: Bot is unable to properly connect to certain Discord voice servers
Git commit reference cd5b9cab3fb6a49ece575e0f86475268f886766b
Describe the bug
The problem is that on_voice_ready callback is not called when bot connects to certain voice channels.
Example of successful voice server connection:
- DPP logs show this:
DEBUG: Sending op 4 to join VC, guild xxx channel xxxDEBUG: Connecting voice for guild xxx channel xxxDEBUG: Connecting new voice session...DEBUG: Voice websocket established; UDP endpoint: xxx.xxx.xxx.xxx:xxx [ssrc=xxx] with 7 modesDEBUG: External IP address: xxx.xxx.xxx.xxx - Bot connects with following request:
GET /?v=4 HTTP/1.1Host: russia8508.discord.mediapragma: no-cacheUser-Agent: DPP/0.1Upgrade: WebSocketConnection: UpgradeSec-WebSocket-Key: xxxSec-WebSocket-Version: 13 - Server responds with HTTP 101 response:
HTTP/1.1 101 Switching ProtocolsConnection: upgradesec-websocket-accept: xxxupgrade: websocketCF-Cache-Status: DYNAMICReport-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=xxx"}],"group":"cf-nel","max_age":604800}NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}Strict-Transport-Security: max-age=15552000; includeSubDomains; preloadX-Content-Type-Options: nosniffServer: cloudflareCF-RAY: xxx-DME - Server sends JSON payload:
1{"op":8,"d":{"v":4,"heartbeat_interval":13750.0}}Connection: upgradesec-websocket-accept: xxxupgrade: websocketCF-Cache-Status: DYNAMICReport-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=xxx"}],"group":"cf-nel","max_age":604800}NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}Strict-Transport-Security: max-age=15552000; includeSubDomains; preloadX-Content-Type-Options: nosniffServer: cloudflareCF-RAY: xxx-DME - Connection proceeds.
on_voice_readycallback is called.
Example of erroneous voice server connection in different Discord guild:
- DPP logs show this:
DEBUG: Sending op 4 to join VC, guild xxx channel xxxDEBUG: Connecting voice for guild xxx channel xxxNothing happens after that. - Bot connects with following request:
GET /?v=4 HTTP/1.1Host: tel-aviv10001.discord.mediapragma: no-cacheUser-Agent: DPP/0.1Upgrade: WebSocketConnection: UpgradeSec-WebSocket-Key: xxxSec-WebSocket-Version: 13 - Server responds with HTTP 400 response:
HTTP/1.1 400 Bad requestContent-Type: text/htmlTransfer-Encoding: chunkedConnection: keep-aliveCache-Control: no-cacheCF-Cache-Status: DYNAMICReport-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=xxx"}],"group":"cf-nel","max_age":604800}NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}Strict-Transport-Security: max-age=15552000; includeSubDomains; preloadX-Content-Type-Options: nosniffServer: cloudflareCF-RAY: xxx-DME5a<html><body><h1>400 Bad request</h1>Your browser sent an invalid request.</body></html> - By design of
dpp::discord_voice_client::thread_run()function bot tries to reconnect. Steps 2 and 3 are repeated infinitely. It may be important to mention that in Discord client bot actually connects to voice channel and sits there even when HTTP 400 error occurs.
To Reproduce
Issue appears to only occur when bot connects to tel-avivXXXXX.discord.media Discord voice servers. The problematic servers do work in Discord desktop clients, so I think the problem is with the library.
Steps to reproduce the behavior:
- Connect to voice channel that is served by
tel-avivXXXXX.discord.mediavoice server. - Make the bot connect to it, for example call
dpp::guild::connect_member_voice(). - Observe that
on_voice_readycallback is never called although bot connects to voice channel in Discord UI.
Expected behavior
Bot should properly connect to voice server and on_voice_ready callback should be called.
System Details:
- Tried it on both
Linux PC 5.15.90.1-microsoft-standard-WSL2 #1 SMP x86_64 x86_64 x86_64 GNU/LinuxandLinux rpi4 6.1.21-v8+ #1642 SMP PREEMPT aarch64 GNU/LinuxOSes. - Desktop Discord Client was used for testing
Some of my assumptions/terms may be wrong because I tried to get how DPP source code works manually.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 39 (27 by maintainers)
Commits related to this issue
- fix: base64 encoding ws key should fix #714 — committed to brainboxdotcc/DPP by braindigitalis 9 months ago
- fix: should fix #714, closes out issue where length of websocket-sec-key was wrong — committed to brainboxdotcc/DPP by braindigitalis 9 months ago
- fix: should fix #714, closes out issue where length of websocket-sec-key was wrong (#900) — committed to brainboxdotcc/DPP by braindigitalis 9 months ago
Can confirm this finally works.
rpi4, aarch64, g++ (Debian 10.2.1-6) 10.2.1 20210110