JDA icon indicating copy to clipboard operation
JDA copied to clipboard

Exception in WS read thread: RSV1 bit of a frame is set unexpectedly

Open freya022 opened this issue 1 year ago • 11 comments

General Troubleshooting

  • [X] I have checked for similar issues on the Issue-tracker.
  • [X] I have checked for PRs that might already address this issue.

Version of JDA

5.0.0-beta.18

Expected Behaviour

Handle the frame gracefully I guess?

Code Example for Reproduction Steps

N/A

Code for JDABuilder or DefaultShardManagerBuilder used

JDABuilder.createLight(token)
            .enableIntents(GatewayIntent.MESSAGE_CONTENT)
            .setActivity(Activity.customStatus("I need more bullets"))
            .setEventManager(/* */)
            .build()

Exception or Error

08:23:31.148 JDA MainWS-ReadThread      n.d.j.i.requests.WebSocketClient     #onError                  L1113  WebSocketClient      ERROR  There was an error in the WebSocket connection
com.neovisionaries.ws.client.WebSocketException: The RSV1 bit of a frame is set unexpectedly.
	at com.neovisionaries.ws.client.ReadingThread.verifyReservedBit1(ReadingThread.java:481)
	at com.neovisionaries.ws.client.ReadingThread.verifyReservedBits(ReadingThread.java:451)
	at com.neovisionaries.ws.client.ReadingThread.verifyFrame(ReadingThread.java:421)
	at com.neovisionaries.ws.client.ReadingThread.readFrame(ReadingThread.java:341)
	at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:99)
	at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
	at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

BEFORE REPORTING A SIMILAR ERROR

Please update to the JDA snapshot https://github.com/discord-jda/JDA/issues/2663#issuecomment-2091841521 and include the WebSocket trace with the error

freya022 avatar Apr 22 '24 22:04 freya022

The latest master commit added a new trace information to further investigate this issue, please let me know when you encounter the error including that trace detail.

MinnDevelopment avatar Apr 23 '24 20:04 MinnDevelopment

I tried this and it works fine in my environment I used JDK 17 and dependencies {implementation("net.dv8tion:JDA:5.0.0-beta.18")} and run by InteliJ This is my test code and result

import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.requests.GatewayIntent;

public class BotApplication {

    public static void main(String[] args) {
        JDABuilder.createLight(Bot.token) // my test token
            .enableIntents(GatewayIntent.MESSAGE_CONTENT)
            .setActivity(Activity.customStatus("I need more bullets"))
            .setEventManager(null)
            .build();
    }
}

스크린샷 2024-04-24 오후 9 35 32

스크린샷 2024-04-24 오후 9 35 21

JayMaro avatar Apr 24 '24 12:04 JayMaro

This is not an issue on startup, it happens at random times, days after the bot started, multiple people have reported this issue, I've created this issue for tracking purpose, so it can also be linked when a fix is available

freya022 avatar Apr 24 '24 12:04 freya022

Oh, I see. I didn't know that. Thank you for telling me. :)

JayMaro avatar Apr 24 '24 12:04 JayMaro

Got one running main: https://duncte123.sentry.io/share/issue/fac5e12d2d2c40bc8baa0a46f21fc64f/

duncte123 avatar Apr 26 '24 03:04 duncte123

Got one running 5.0.0-beta.23

rakosi2 avatar May 02 '24 21:05 rakosi2

Got one running 5.0.0-beta.23

Please send the exception with the WS trace, like duncte123 sent

freya022 avatar May 02 '24 21:05 freya022

I don't think I have WS trace enabled or how to retrieve it. I have the stacktrace that is the same as the OP [2024/05/02 23:20:23] [ERROR] [JDA MainWS-ReadThread] ERROR WebSocketClient - There was an error in the WebSocket connection com.neovisionaries.ws.client.WebSocketException: The RSV1 bit of a frame is set unexpectedly. at com.neovisionaries.ws.client.ReadingThread.verifyReservedBit1(ReadingThread.java:481) at com.neovisionaries.ws.client.ReadingThread.verifyReservedBits(ReadingThread.java:451) at com.neovisionaries.ws.client.ReadingThread.verifyFrame(ReadingThread.java:421) at com.neovisionaries.ws.client.ReadingThread.readFrame(ReadingThread.java:341) at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:99) at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45) [2024/05/02 23:20:23] [ERROR] Exception while handling JDA event:: com.neovisionaries.ws.client.WebSocketException: The RSV1 bit of a frame is set unexpectedly. at com.neovisionaries.ws.client.ReadingThread.verifyReservedBit1(ReadingThread.java:481) at com.neovisionaries.ws.client.ReadingThread.verifyReservedBits(ReadingThread.java:451) at com.neovisionaries.ws.client.ReadingThread.verifyFrame(ReadingThread.java:421) at com.neovisionaries.ws.client.ReadingThread.readFrame(ReadingThread.java:341) at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:99) at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64) at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

rakosi2 avatar May 02 '24 22:05 rakosi2

Ah yea, please updated to the latest snapshot:

Maven:

<repositories>
    <repository>
        <id>jitpack</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>io.github.discord-jda</groupId>
        <artifactId>JDA</artifactId>
        <version>6f7189f91a</version>
    </dependency>
</dependencies>

Gradle (Kotlin):

repositories {
    mavenCentral()
    maven("https://jitpack.io")
}

dependencies {
    implementation("io.github.discord-jda:JDA:6f7189f91a")
}

freya022 avatar May 02 '24 22:05 freya022

I have updated my POM, will see if I get it again. https://github.com/Slaynash/Lumbot/commit/d30becdef1d36d21bbf3d425a7fd18ba68fb8ed5

rakosi2 avatar May 02 '24 22:05 rakosi2

This issue has been escalated to cloudflare. Apparently, the web socket is receiving an http response body instead of a web socket frame. The specific bit happens to be set when the frame starts with HTTP/1.1 502 Bad Gateway Server.

MinnDevelopment avatar May 12 '24 14:05 MinnDevelopment

This should be fixed as of last Friday.

MinnDevelopment avatar May 28 '24 18:05 MinnDevelopment