From 9f8cad3df5c68466ae2a1eec58e976c1a9fe6706 Mon Sep 17 00:00:00 2001 From: Chelsea <110854802+ckwong17@users.noreply.github.com> Date: Thu, 22 Sep 2022 01:38:55 -0400 Subject: [PATCH] Fix webSocket not closed in onClosing Inside Android's Okhttp onClosing callback, we need to manually close the websocket, in order to trigger a reconnect. https://github.com/square/okhttp/issues/3386 --- src/main/kotlin/org/phoenixframework/Transport.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/phoenixframework/Transport.kt b/src/main/kotlin/org/phoenixframework/Transport.kt index 25c8818..decf354 100644 --- a/src/main/kotlin/org/phoenixframework/Transport.kt +++ b/src/main/kotlin/org/phoenixframework/Transport.kt @@ -155,6 +155,7 @@ class WebSocketTransport( override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { this.readyState = Transport.ReadyState.CLOSING + webSocket.close(code, reason) } override fun onMessage(webSocket: WebSocket, text: String) { @@ -165,4 +166,4 @@ class WebSocketTransport( this.readyState = Transport.ReadyState.CLOSED this.onClose?.invoke(code) } -} \ No newline at end of file +}