Skip to content
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

Closed
ivorcho opened this issue Oct 5, 2017 · 5 comments
Closed

Android RuntimeException thrown by WebSocketModule in send #16214

ivorcho opened this issue Oct 5, 2017 · 5 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@ivorcho
Copy link

ivorcho commented Oct 5, 2017

Hello,

We are experiencing a rare and hard to reproduce crash on Android devices caused by RuntimeException thrown by com.facebook.react.modules.websocket.WebSocketModule in send() 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!

@mjroeleveld
Copy link

mjroeleveld commented Oct 5, 2017

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 WebSocketModule.send errors but also more cryptic errors such as Unhandled "error" event. (Invalid namespace) and Error: websocket error happen all the time.

https://sentry.io/share/issue/3231323938322e333533313833373637/

@pull-bot
Copy link

@facebook-github-bot no-template

@facebook-github-bot
Copy link
Contributor

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.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Oct 10, 2017
@yedidyak
Copy link
Contributor

yedidyak commented Dec 4, 2017

Looks like it's the same as #3346

@ghost
Copy link

ghost commented Dec 7, 2017

Same issue here. Running RN 0.51.0

@facebook facebook locked as resolved and limited conversation to collaborators Oct 10, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants