This commit fixes a crash where we attempt to close the websocket on the main thread after a timeout.
The crash causes the retry logic to fail and then our device never connects to the debug server.
Here is the following crash:
07-27 15:55:11.216 29240 29240 E AndroidRuntime: FATAL EXCEPTION: main
07-27 15:55:11.216 29240 29240 E AndroidRuntime: Process: com.deako.android.home.dev, PID: 29240
07-27 15:55:11.216 29240 29240 E AndroidRuntime: android.os.NetworkOnMainThreadException
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at java.net.SocketOutputStream.write(SocketOutputStream.java:157)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okio.Okio$1.write(Okio.java:78)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okio.AsyncTimeout$1.write(AsyncTimeout.java:180)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okio.RealBufferedSink.emit(RealBufferedSink.java:178)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okhttp3.internal.ws.WebSocketWriter.writeControlFrameSynchronized(WebSocketWriter.java:152)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okhttp3.internal.ws.WebSocketWriter.writeClose(WebSocketWriter.java:111)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:168)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at com.facebook.react.devsupport.JSDebuggerWebSocketClient.closeQuietly(JSDebuggerWebSocketClient.java:144)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at com.facebook.react.devsupport.WebsocketJavaScriptExecutor$3.run(WebsocketJavaScriptExecutor.java:148)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6236)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
07-27 15:55:11.216 29240 29240 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)