serenity-rs/songbird

Our application can no longer connect to the voice channel.

abokado0107 opened this issue · 7 comments

Songbird version: (version)
0.3.0

Rust version (rustc -V): (version)
rustc 1.65.0 (897e37553 2022-11-02)

Serenity/Twilight version: (version)
Serenity 0.11.5

Output of ffmpeg -version, yt-dlp --version (if relevant):
ffmpeg version 4.2.4-1ubuntu0.1

Description:
Our application can no longer connect to the voice channel.
To be more precise, it connects, but we can no longer speak.

<unknown time> DEBUG runner{config=Config { crypto_mode: Normal, decode_mode: Decrypt, gateway_timeout: Some(10s), preallocated_tracks: 1, driver_retry: Retry { strategy: Backoff(ExponentialBackoff { min: 250ms, max: 10s, jitter: 0.1 }), retry_limit: Some(5) }, driver_timeout: Some(10s) }}: /home/renne/.cargo/registry/src/github.com-1ecc6299db9ec823/songbird-0.3.0/src/driver/connection/mod.rs:335: Expected ready for key; got: op5/vSpeaking(Speaking { delay: None, speaking: MICROPHONE, ssrc: 5166, user_id: Some(UserId(438191250437308417)) })
<unknown time> DEBUG runner{config=Config { crypto_mode: Normal, decode_mode: Decrypt, gateway_timeout: Some(10s), preallocated_tracks: 1, driver_retry: Retry { strategy: Backoff(ExponentialBackoff { min: 250ms, max: 10s, jitter: 0.1 }), retry_limit: Some(5) }, driver_timeout: Some(10s) }}: /home/renne/.cargo/registry/src/github.com-1ecc6299db9ec823/songbird-0.3.0/src/driver/tasks/mod.rs:300: Failed to connect for GuildId(940648772772442143): failed to connect to Discord RTP server: websocket issue (Json(Error("invalid value: integer `18`, expected opcode in [0--9] + [12--13]", line: 1, column: 8))).

From the log above, it is possible that something called opcode 18 is being sent and it is no longer working properly.

Steps to reproduce:

Songbird sample code doesn't work.

https://github.com/serenity-rs/songbird/blob/current/examples/serenity/voice/src/main.rs

Work:
Connect to VC normally.

Erk- commented

This is fixed by #170, though the final solution will be a bit different than the current pr.

I received a similar error in one of my bug reports.

For my case, it produced 2 different error messages.

Error 1

    let (_handle_lock, success) = manager.join(guild_id, connect_to).await;

    let reply = match dbg!(success) {
        Ok(_) => format!("Joined {}", connect_to.mention()),
        Err(e) =>format!("Failed to join voice channel: {:?}", e),
    };

The bot replies with:
Failed to join voice channel: Driver(Ws(WsClosed(Some(CloseFrame { code: Library(4006), reason: "Session is no longer valid." }))))

Error 2

If the voice state is changed (forced by switching bot between VC channels), I was then prompted with the same error as this issue. Prompted on the same code block as above.

Failed to join voice channel: Driver(Ws(Json(Error("invalid value: integer 18, expected opcode in [0--9] + [12--13]", line: 1, column: 8))))

Edit

I can confirm similar behavior as above, bot is able to join VC-channel, but unable to emit audio

I also have this issue.
I'm using songbird-py so the error message is slightly different, but definitely seems like the same issue.

Also having a similar issue via songbird-py . Connects but won't play anything and throws this trace:

Traceback (most recent call last):
  File "/home/pi/DiscordBots/RB/bot/extensions/shortcuts.py", line 402, in countdown_timer
    voice = await Voicebox.connect(bot, guild_id, user_voice_channel_id)
  File "/home/pi/.local/lib/python3.9/site-packages/songbird/hikari.py", line 19, in connect
    return await client.voice.connect_to(
  File "/home/pi/.local/lib/python3.9/site-packages/hikari/impl/voice.py", line 209, in connect_to
    voice_connection = await voice_connection_type.initialize(
  File "/home/pi/.local/lib/python3.9/site-packages/songbird/hikari.py", line 40, in initialize
    await driver.connect(
module.CouldNotConnectToRTPError: Ws(WsClosed(Some(CloseFrame { code: Library(4006), reason: "Session is no longer valid." })))

The contributor worked around this problem.
If you are using Cargo.toml to manage your crate, please change the contents of songbird as follows:

[dependencies.songbird]
features = ["builtin-queue"]
git = "https://github.com/Erk-/songbird/"
branch = "do-not-fail-if-new-opcode"

Note, however, that this is not an official serenity crate.
This is a temporary solution, and once this branch is merged into serenity, you should use the official one.
And perhaps in a little while this branch will be merged into serenity.

Songbird 0.3.2 has been released with the fix to this issue https://github.com/serenity-rs/songbird/releases/tag/v0.3.2

I think this issue can be closed?

Sure, closed by #170.

I don't know if 'error 1' is the same issue or some weird knock-on -- if this persists on v0.3.2, please reopen. This should be ported to next once I have access to a computer again.