mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-24 01:50:24 +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 func() {
|
||||
disconnectAfter := time.Duration(3) * time.Minute
|
||||
disconnectAfter := 3 * time.Minute
|
||||
timeout := time.After(disconnectAfter)
|
||||
|
||||
<-time.After(disconnectAfter)
|
||||
|
||||
defer func() {
|
||||
select {
|
||||
case <-timeout:
|
||||
logging.Info("Connection closed after", disconnectAfter)
|
||||
|
||||
client.hub.unregister <- client
|
||||
client.conn.Close()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user