You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using MockWebServer to test a WebSocket client which should be able to gracefully deal with an scenario where the server closes the connection without a status code (1005) or doesn't send a close frame at all (1006).
I'd expect to be able to call websocket.close() to replicate the former, but WebSocket.close() requires a code. But if I set 1005, OkHTTP rejects it (as it should per the spec). That means I don't have a way to replicate a 1005.
On the other hand, I'd expect to be able to replicate a 1006 by calling websocket.cancel(). However, I get a NullPointerException because RealWebSocket.cancel() seems to be reserved for client sockets:
I'm using MockWebServer to test a WebSocket client which should be able to gracefully deal with an scenario where the server closes the connection without a status code (
1005
) or doesn't send a close frame at all (1006
).I'd expect to be able to call
websocket.close()
to replicate the former, butWebSocket.close()
requires a code. But if I set1005
, OkHTTP rejects it (as it should per the spec). That means I don't have a way to replicate a1005
.On the other hand, I'd expect to be able to replicate a
1006
by callingwebsocket.cancel()
. However, I get aNullPointerException
becauseRealWebSocket.cancel()
seems to be reserved for client sockets:okhttp/okhttp/src/main/kotlin/okhttp3/internal/ws/RealWebSocket.kt
Lines 70 to 71 in 9ee3344
okhttp/okhttp/src/main/kotlin/okhttp3/internal/ws/RealWebSocket.kt
Lines 142 to 144 in 9ee3344
The text was updated successfully, but these errors were encountered: