-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android RuntimeException thrown by WebSocketModule in send #16214
Comments
We experience the same problems with an app relying heavily on websockets. React Native seems to have problems with websockets when the app is sent to the background and then coming back. We get the same https://sentry.io/share/issue/3231323938322e333533313833373637/ |
@facebook-github-bot no-template |
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See "What to Expect from Maintainers" to learn more. |
Looks like it's the same as #3346 |
Same issue here. Running RN 0.51.0 |
Hello,
We are experiencing a rare and hard to reproduce crash on Android devices caused by
RuntimeException
thrown bycom.facebook.react.modules.websocket.WebSocketModule
insend()
method. We have difficulties to reproduce this error, but we are getting reports about it happening in Play Store. Here is the full stack trace:java.lang.RuntimeException: Cannot send a message. Unknown WebSocket id 7 at com.facebook.react.modules.websocket.WebSocketModule.send(WebSocketModule.java:226) at java.lang.reflect.Method.invoke(Method.java) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:154) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) at java.lang.Thread.run(Thread.java:762)
We are using
"socket.io-client": "2.0.1"
for socket connection and"react-native": "0.48.4"
.From the source code I see this is happening when there is no such WebSocket client in the array of sockets. But what could lead to that? Maybe there is something wrong on how JS socket.io connections are handled by the native code. The comment is pointing it's a programmer error :D
public void send(String message, int id) { WebSocket client = mWebSocketConnections.get(id); if (client == null) { // This is a programmer error throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id); } try { client.send(message); } catch (Exception e) { notifyWebSocketFailed(id, e.getMessage()); } }
I see others have experienced this error as well, but because of the crash being sporadic and difficult to reproduce all issues have been closed :(.
Any kind of help will be appreciated. Thanks!
The text was updated successfully, but these errors were encountered: