Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

OkHttpWebsocketSession does not complete the `closeReason` future when closing the websocket in absence of connectivity

Aperta
#8,678 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@jcovington16 ci sta già lavorando.

Dal 5/3/2025.

  • #9188 di @MohitAnuragi — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
kotlin
Ambito
networking

Direzione di ricerca

Start by reading OkHttpWebsocketSession and the RealWebSocket callbacks mentioned in the issue, focusing on how closeReason is completed by onClosing, onClosed, and onFailure. Reproduce the described disconnect-and-close sequence with ping-pong disabled; done means the coroutine awaiting closeReason terminates when the websocket is closed without connectivity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Hello! 👋
I encountered this issue while doing some tests for the reliability of my ktor-based client application.

Reproduction steps

  • Initialize a ktor application with websocket and where the built-in ping-pong mechanism is disabled.
  • Launch 2 coroutines: Coroutine 1 communicates through websocket with a server external to the machine, Coroutine 2 awaits the completion of the closeReason Future through DefaultWebSocketSession.closeReason.
  • Disconnect the machine from the internet.
  • Close the websocket.

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, the closeReason future is completed only in one of these 3 method: onClosing, onClosed, or onFailure.

  • onFailure is not called by the RealWebSocket implementation when the connection drops because we disabled the built-in ping/pong mechanism in favour of a custom one.
  • onClosing and onClose 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?

Lingua principale
Kotlin
Stelle
47.1k
Fork
9.3k
Merge medio
18h 18m
PR unite (30g)
15

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lysine-dev/okhttp

Tutte le issue di lysine-dev/okhttp

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.