react-native: [Android] `Cannot close WebSocket.` repeatedly
I upgraded my project from 0.28 to 0.30 and since I have, on Android, this warning message every 2-3 seconds:
Cannot close WebSocket. Unknown WebSocket id 0
With the id increasing.
I did a fresh react-native init
and it also appears. So it’s not my project related.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 26
- Comments: 66 (11 by maintainers)
+1 with RN 0.44 and Firebase 3.9.0, both Android and iOS
+1 We are having A LOT of crashes in production! Is there any progress on this issue?
@jiyarong I have the following code in place:
but I can still get the error.
@jiyarong the thing is that this error appears after network reconnect on
ws.send()
. This happens only on Android. iOS is good. The correct behaviour must be like on iOS: the application must go to websocket onError and there must be graceful websocket recreation. But the Android version just crashes.Same. I get this issue both in debug and production releases on Google Play. I only get this issue on Android.
I’ve got a similar issue. After a network reconnect I’ve got this one:
On iOS there is no such error. I’ve got the app logic to close the websocket after network reconnect and open a new one. On iOS this logic works perfectly. But on Android I’ve this error. I guess the nature of this error is the same as in the original post. What are we going to do about it?
Similar Issue: RN : 0.42 Happens so often on remote debugging.
` E/unknown:React: Exception in native call java.lang.RuntimeException: Cannot send a message. Unknown WebSocket id 2 at com.facebook.react.modules.websocket.WebSocketModule.send(WebSocketModule.java:221) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345) at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:136) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) 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:148) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818)
`
We’re using RN 0.43.4, Firebase 3.9.0 and experiencing this on Android only.