failed to close writer: context canceled
@mafredri ya está trabajando en esto.
Desde el 11/12/2024.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
I'm using this library to create a zero-trust tunnel into a Kubernetes cluster, when I encountered this error message:
failed to write msg: failed to close writer: failed to acquire lock: context canceled
So what happened was that when client closed the connection, I would send a "connection closed" message over the WebSocket connection, but I (mistakenly) used the request context for the write command.
This context would get cancelled somewhere around this Write call, sometimes after message was written but before it released the lock.
As a result, the lock would never get released and the websocket was no longer usable.
The solution was to create a new context for the write:
writeCtx, _ := context.WithTimeout(context.Background(), 2*time.Second)
err = c.Websocket.Write(writeCtx, websocket.MessageText, marshal)
And I don't think I should have used the request context to begin with, but I do think it's not optimal behaviour that the websocket can be left in a broken state by mistimed context cancel.
In any case, just thought I'd share it. Thanks for maintaining this awesome library!
- Lenguaje dominante
- Go
- Estrellas
- 5.5k
- Forks
- 377
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de coder/websocket
-
Must not wrap io.EOF Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
export wstest Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Todos los issues de coder/websocket
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
bug group: validation priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
codecheckers/chekhov#51 ·
-
Creating worktree from an existing remote branch with a slash in it, has unexpected behaviour Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100