OkHttpWebsocketSession does not complete the closeReason
future when closing the websocket in absence of connectivity
#8678
Labels
bug
Bug in existing code
Hello! 👋
I encountered this issue while doing some tests for the reliability of my ktor-based client application.
Reproduction steps
closeReason
Future throughDefaultWebSocketSession.closeReason
.Actual Behaviour
Coroutine 1 terminates while Coroutine 2 hangs forever.
Expected Behaviour
Coroutine 2 should also terminate, as
closeReason
should complete.Analysis
Looking at the code, my understanding of the reason of this behaviour is that, in the
OkHttpWebsocketSession
class, thecloseReason
future is completed only in one of these 3 method:onClosing
,onClosed
, oronFailure
.onFailure
is not called by theRealWebSocket
implementation when the connection drops because we disabled the built-in ping/pong mechanism in favour of a custom one.onClosing
andonClose
are not called when the websocket is closed unless a control frame (OPCODE_CONTROL_CLOSE
) is sent by the server, event that cannot happen under these conditions.Additional Information
On the other hand, the CIO engine manages to complete the
closeReason
future under the same assumptions.Question
Is this a design choice or just a bug due to a very niche condition?
The text was updated successfully, but these errors were encountered: