From 2e465bca158ae9cfa89448e2a3bb8cc009397ac8 Mon Sep 17 00:00:00 2001 From: Ranjan Shrestha Date: Tue, 13 Nov 2018 23:17:25 -0800 Subject: [PATCH] Android: Close websocket properly when remote server initiates close (#22248) Summary: When the remote server closes the websocket, the app doesn't get a 'close' event in Android, There is no issue on iOS. Pull Request resolved: https://github.com/facebook/react-native/pull/22248 Differential Revision: D13047556 Pulled By: hramos fbshipit-source-id: c5c56ea8418cfdf734fb51f863b3066856de6512 --- .../facebook/react/modules/websocket/WebSocketModule.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java index 33d8644eeabff7..5843ec44ae34c0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java @@ -147,6 +147,11 @@ public void onOpen(WebSocket webSocket, Response response) { sendEvent("websocketOpen", params); } + @Override + public void onClosing(WebSocket websocket, int code, String reason) { + websocket.close(code, reason); + } + @Override public void onClosed(WebSocket webSocket, int code, String reason) { WritableMap params = Arguments.createMap();