Skip to content

Commit

Permalink
Fix webSocket not closed in onClosing
Browse files Browse the repository at this point in the history
Inside Android's Okhttp onClosing callback, we need to manually close the websocket, in order to trigger a reconnect.
square/okhttp#3386
  • Loading branch information
ckwong17 authored Sep 22, 2022
1 parent faebdc3 commit 9f8cad3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/org/phoenixframework/Transport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -165,4 +166,4 @@ class WebSocketTransport(
this.readyState = Transport.ReadyState.CLOSED
this.onClose?.invoke(code)
}
}
}

0 comments on commit 9f8cad3

Please sign in to comment.