gateway-proxy icon indicating copy to clipboard operation
gateway-proxy copied to clipboard

Voice support

Open KagChi opened this issue 2 years ago • 10 comments

Hey, thanks for making great lib !

I have several question:

  • If client connect to this proxy and connected to voice, when client disconnected from proxy will that make the voice session became invalid?

I have tested this proxy with lavalink and when the client disconnected from the proxy. discord sent invalid session to voice gateway. i dont know is it my problem or this proxy problem.

KagChi avatar Jun 14 '22 15:06 KagChi

Hi there, as mentioned in the README, voice is currently unsupported and probably not working after a client restart. This might be different in the case of lavalink, but I haven't tried it. Voice sessions however should not get invalid because the proxy remains connected.

Gelbpunkt avatar Jul 08 '22 12:07 Gelbpunkt

Any ETA on when voice support will be added again?

DJCoolDev avatar Mar 03 '23 19:03 DJCoolDev

Any ETA on when voice support will be added again?

Sorry for the late reply. There is no ETA because I don't have the knowledge of how Discord handles voice clients over the gateway and I don't have a bot that utilizes this, so it would be hard for me to test and maintain it.

Gelbpunkt avatar Apr 08 '23 13:04 Gelbpunkt

Can you test the voice branch and let me know if it works for you please?

Gelbpunkt avatar Apr 15 '23 19:04 Gelbpunkt

Sorry for the late reply, I had some other stuff around, but I finally managed to test it. I can connect to the non voice version without any issues, but when using the voice version of the gateway proxy I don't get any events in the client. Here is the log that may be helpful:

gateway-proxy   | 2023-04-25T22:16:08.523488Z DEBUG twilight_http::client: url="https://discord.com/api/v10/gateway/bot"
gateway-proxy   | 2023-04-25T22:16:08.523526Z DEBUG twilight_http_ratelimiting::in_memory: getting bucket for path: GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.523530Z DEBUG twilight_http_ratelimiting::in_memory: making new bucket for path: GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.523612Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: starting to get next in queue path=GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.523651Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: starting to wait for response headers
gateway-proxy   | 2023-04-25T22:16:08.523786Z DEBUG hyper::client::connect::dns: resolving host="discord.com"
gateway-proxy   | 2023-04-25T22:16:08.541180Z DEBUG hyper::client::connect::http: connecting to 162.159.137.232:443
gateway-proxy   | 2023-04-25T22:16:08.559004Z DEBUG hyper::client::connect::http: connected to 162.159.137.232:443
gateway-proxy   | 2023-04-25T22:16:08.578451Z DEBUG h2::client: binding client connection
gateway-proxy   | 2023-04-25T22:16:08.578476Z DEBUG h2::client: client connection bound
gateway-proxy   | 2023-04-25T22:16:08.578480Z DEBUG h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
gateway-proxy   | 2023-04-25T22:16:08.578555Z DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
gateway-proxy   | 2023-04-25T22:16:08.578620Z DEBUG hyper::client::pool: pooling idle connection for ("https", discord.com)
gateway-proxy   | 2023-04-25T22:16:08.578762Z DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
gateway-proxy   | 2023-04-25T22:16:08.594678Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 256, initial_window_size: 65536, max_frame_size: 16777215 }
gateway-proxy   | 2023-04-25T22:16:08.594712Z DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
gateway-proxy   | 2023-04-25T22:16:08.594718Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 }
gateway-proxy   | 2023-04-25T22:16:08.595247Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
gateway-proxy   | 2023-04-25T22:16:08.595268Z DEBUG Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
gateway-proxy   | 2023-04-25T22:16:08.740666Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
gateway-proxy   | 2023-04-25T22:16:08.740708Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1) }
gateway-proxy   | 2023-04-25T22:16:08.740713Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
gateway-proxy   | 2023-04-25T22:16:08.740894Z DEBUG twilight_http::client: url="https://discord.com/api/v10/gateway/bot"
gateway-proxy   | 2023-04-25T22:16:08.740915Z DEBUG twilight_http_ratelimiting::in_memory: getting bucket for path: GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.740918Z DEBUG twilight_http_ratelimiting::in_memory: got existing bucket: GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.740920Z DEBUG twilight_http_ratelimiting::in_memory: added request into bucket queue: GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.740920Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: updating bucket path=GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.740952Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: starting to get next in queue path=GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.740981Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: starting to wait for response headers
gateway-proxy   | 2023-04-25T22:16:08.741075Z DEBUG hyper::client::pool: reuse idle connection for ("https", discord.com)
gateway-proxy   | 2023-04-25T22:16:08.741179Z DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(3), flags: (0x5: END_HEADERS | END_STREAM) }
gateway-proxy   | 2023-04-25T22:16:08.899597Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(3), flags: (0x4: END_HEADERS) }
gateway-proxy   | 2023-04-25T22:16:08.899634Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
gateway-proxy   | 2023-04-25T22:16:08.899638Z DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3), flags: (0x1: END_STREAM) }
gateway-proxy   | 2023-04-25T22:16:08.899763Z  INFO twilight_gateway_queue::large_bot_queue: 2/1000 identifies used before next reset in 86069.96s
gateway-proxy   | 2023-04-25T22:16:08.899781Z  INFO gateway_proxy: Creating shards 0 to 0 of 1 total
gateway-proxy   | 2023-04-25T22:16:08.899848Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: updating bucket path=GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.899854Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: starting to get next in queue path=GatewayBot
gateway-proxy   | 2023-04-25T22:16:08.899858Z DEBUG background queue task{path=GatewayBot}:waiting for bucket to refresh{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: 0 tickets remaining, may have to wait
gateway-proxy   | 2023-04-25T22:16:08.899860Z DEBUG background queue task{path=GatewayBot}:waiting for bucket to refresh{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: waiting for ratelimit to pass milliseconds=4841
gateway-proxy   | 2023-04-25T22:16:08.900108Z DEBUG gateway_proxy: Created shard 0 of 1 total
gateway-proxy   | 2023-04-25T22:16:08.900148Z  INFO gateway_proxy::server: Listening on 0.0.0.0:7878
gateway-proxy   | 2023-04-25T22:16:09.504775Z DEBUG hyper::proto::h1::io: parsed 6 headers
gateway-proxy   | 2023-04-25T22:16:09.504805Z DEBUG hyper::proto::h1::conn: incoming body is empty
gateway-proxy   | 2023-04-25T22:16:09.504890Z DEBUG hyper::proto::h1::io: flushed 193 bytes
gateway-proxy   | 2023-04-25T22:16:09.506564Z DEBUG gateway_proxy::server: [172.21.0.1:50996] Client is identifying
gateway-proxy   | 2023-04-25T22:16:09.506626Z DEBUG gateway_proxy::server: [Shard 0] Starting to send events to client
gateway-proxy   | 2023-04-25T22:16:09.901314Z DEBUG shard{id=[0, 1]}:connect: twilight_gateway::connection: shaking hands with gateway url="wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream"
gateway-proxy   | 2023-04-25T22:16:10.116352Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received hello heartbeat_interval=41.25s jitter=6.043267557s
gateway-proxy   | 2023-04-25T22:16:10.116395Z  INFO twilight_gateway_queue::large_bot_queue: waiting for allowance on shard 0
gateway-proxy   | 2023-04-25T22:16:10.116401Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: sending identify
gateway-proxy   | 2023-04-25T22:16:10.326672Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received dispatch event_type=READY sequence=1
gateway-proxy   | 2023-04-25T22:16:10.326785Z DEBUG gateway_proxy::server: [Shard 0] Sending newly created READY
gateway-proxy   | 2023-04-25T22:16:10.328300Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received dispatch event_type=GUILD_CREATE sequence=2
gateway-proxy   | 2023-04-25T22:16:10.333872Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received dispatch event_type=GUILD_CREATE sequence=3
gateway-proxy   | 2023-04-25T22:16:12.988812Z DEBUG Connection{peer=Client}: h2::proto::connection: Connection::poll; IO error error=UnexpectedEof
gateway-proxy   | 2023-04-25T22:16:12.988916Z DEBUG hyper::proto::h2::client: connection error: unexpected end of file
gateway-proxy   | 2023-04-25T22:16:12.988944Z DEBUG hyper::client::client: client connection error: connection error: unexpected end of file
gateway-proxy   | 2023-04-25T22:16:13.741843Z DEBUG background queue task{path=GatewayBot}:waiting for bucket to refresh{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: done waiting for ratelimit to pass
gateway-proxy   | 2023-04-25T22:16:14.415119Z ERROR gateway_proxy::dispatch: Error receiving message: websocket connection error
gateway-proxy   | 2023-04-25T22:16:14.415160Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: gateway connection closed
gateway-proxy   | 2023-04-25T22:16:15.416456Z DEBUG shard{id=[0, 1]}:connect: twilight_gateway::connection: shaking hands with gateway url="wss://gateway-us-east1-c.discord.gg/?v=10&encoding=json&compress=zlib-stream"
gateway-proxy   | 2023-04-25T22:16:15.678869Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received hello heartbeat_interval=41.25s jitter=17.462272807s
gateway-proxy   | 2023-04-25T22:16:15.678914Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: sending resume sequence=3
gateway-proxy   | 2023-04-25T22:16:15.809539Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received dispatch event_type=RESUMED sequence=4
gateway-proxy   | 2023-04-25T22:16:20.992772Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: received dispatch event_type=MESSAGE_CREATE sequence=5
gateway-proxy   | 2023-04-25T22:16:23.742862Z DEBUG background queue task{path=GatewayBot}: twilight_http_ratelimiting::in_memory::bucket: bucket appears finished, removing
gateway-proxy   | 2023-04-25T22:16:31.228259Z ERROR gateway_proxy::dispatch: Error receiving message: websocket connection error
gateway-proxy   | 2023-04-25T22:16:31.228310Z DEBUG shard{id=[0, 1]}: twilight_gateway::shard: gateway connection closed
gateway-proxy   | 2023-04-25T22:16:32.229561Z DEBUG shard{id=[0, 1]}:connect: twilight_gateway::connection: shaking hands with gateway url="wss://gateway-us-east1-c.discord.gg/?v=10&encoding=json&compress=zlib-stream"

DJCoolDev avatar Apr 25 '23 22:04 DJCoolDev

That isn't a very telling log, can you send me your configuration file, and logs with TRACE level? Make sure to redact your token. Would be good to see what your client sends too.

Gelbpunkt avatar Apr 26 '23 18:04 Gelbpunkt

Sure! Token is provided over the env variable and here is my config:

{
  "log_level": "trace",
  "intents": 3276543,
  "shards": 1,
  "port": 7878,
  "activity": {
    "type": 2,
    "name": ",help"
  },
  "status": "online",
  "externally_accessible_url": "ws://localhost:7878",
  "cache": {
    "channels": true,
    "presences": false,
    "emojis": false,
    "current_member": true,
    "members": true,
    "roles": true,
    "stage_instances": false,
    "stickers": false,
    "users": true,
    "voice_states": true
  }
}

Here is the error log with the trace level, the issue in the logs only happens if the bot is connected to the proxy and also happens without any human interactions: https://pastebin.com/7fTTemGm

DJCoolDev avatar Apr 28 '23 20:04 DJCoolDev

Sure! Token is provided over the env variable and here is my config:

{
  "log_level": "trace",
  "intents": 3276543,
  "shards": 1,
  "port": 7878,
  "activity": {
    "type": 2,
    "name": ",help"
  },
  "status": "online",
  "externally_accessible_url": "ws://localhost:7878",
  "cache": {
    "channels": true,
    "presences": false,
    "emojis": false,
    "current_member": true,
    "members": true,
    "roles": true,
    "stage_instances": false,
    "stickers": false,
    "users": true,
    "voice_states": true
  }
}

Here is the error log with the trace level, the issue in the logs only happens if the bot is connected to the proxy and also happens without any human interactions: https://pastebin.com/7fTTemGm

There is no issue in the logs you provided here. What I can actually see is that there was an issue introduced in a recent commit (which is on both the voice and the main branch) that caused zlib compression to be enabled pretty much in all cases. Could it be that that is causing your issues? As I said I would love to get a client log. I'll push the fix for this to both branches.

Gelbpunkt avatar Apr 29 '23 13:04 Gelbpunkt

Hi there, just poking. Have you been able to test this again?

Gelbpunkt avatar Jun 25 '23 22:06 Gelbpunkt

Hi, sorry for the late reply. Until now, it worked perfectly fine and I had no issues at all after your fix with the zlib compression.

DJCoolDev avatar Jul 03 '23 10:07 DJCoolDev

Its been 2 years since my last comment 😅😅, i can confirm this is working perfectly 👍. waiting arm build for this awesome stuff 😁

KagChi avatar Jun 27 '24 16:06 KagChi