mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-24 18:10:51 +01:00
websocket api: fix websocket connection timeout handling
This commit is contained in:
parent
b8dd4c167a
commit
3fb3b1b794
@ -76,15 +76,15 @@ func (h *ConnectionHandler) serveWs(hub *Hub, w http.ResponseWriter, r *http.Req
|
|||||||
go client.readPump()
|
go client.readPump()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
disconnectAfter := time.Duration(3) * time.Minute
|
disconnectAfter := 3 * time.Minute
|
||||||
|
timeout := time.After(disconnectAfter)
|
||||||
|
|
||||||
<-time.After(disconnectAfter)
|
select {
|
||||||
|
case <-timeout:
|
||||||
defer func() {
|
|
||||||
logging.Info("Connection closed after", disconnectAfter)
|
logging.Info("Connection closed after", disconnectAfter)
|
||||||
|
|
||||||
client.hub.unregister <- client
|
client.hub.unregister <- client
|
||||||
client.conn.Close()
|
client.conn.Close()
|
||||||
}()
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user