You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: java.lang.IllegalArgumentException: Code 1005 is reserved and may not be used.
After investigating the issue I found that the code is returned when the connection was closed but there wasn't any status code. In this case the error code is reserved and so the app crashes. It seems that the library should santise the code before closing the websocket connection as certain codes are reserved.
I'm no expert in terms of the implementation here, however I checked the reserved status codes for websockets and I found the following: https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1. So based on this the following code might be applied:
Is there a way to reproduce this issue? It seems like I can't reproduce this no matter how I close my socket. We're using the exact same logic from React Native
Hi @edusperoni! Sorry for not sending reproducible code, I investigated the issue based on a crash report. Anyway I've managed to create test code to replicate it:
// node ws serverconsthttp=require('http');constWebSocket=require('ws');constserver=http.createServer();constwss=newWebSocket.Server({ server });wss.on('connection',(ws,req)=>{console.log('Client connected');// After 3 seconds, send a close frame WITHOUT a status code.// OkHttp will report this as code 1005 ("No Status Received") in onClosing.setTimeout(()=>{console.log('Sending close frame with no status code...');ws.close();},3000);});server.listen(8080,()=>console.log('Listening on ws://localhost:8080'));
The above code sends a WebSocket close frame without a status code on purpose, which causes code 1005. From what I've read this shouldn't be something that happens often, however it could be that certain failures on the network might result in 1005 status code (or other reserved error codes).
Activity
edusperoni commentedon Feb 13, 2026
Hello!
Is there a way to reproduce this issue? It seems like I can't reproduce this no matter how I close my socket. We're using the exact same logic from React Native
https://github.com/facebook/react-native/blob/369a817cf0aaace85a9b62064daaad337b0eb8b3/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.kt#L152-L154
I need to be able to reproduce this somehow so I can properly report this close event to the user (not with a status 1000).
dangrima90 commentedon Feb 14, 2026
Hi @edusperoni! Sorry for not sending reproducible code, I investigated the issue based on a crash report. Anyway I've managed to create test code to replicate it:
The above code sends a WebSocket close frame without a status code on purpose, which causes code 1005. From what I've read this shouldn't be something that happens often, however it could be that certain failures on the network might result in 1005 status code (or other reserved error codes).
Sample code in an Android app: