read of 0 bytes to detect connection loss.

This commit is contained in:
Erik Brakkee 2024-08-08 00:09:35 +02:00
parent 52ca0f3ecc
commit 85841bcb0f

View File

@ -86,7 +86,13 @@ func (session *WebSession) WriteNotifications(location *time.Location) {
return
}
case <-timer.C:
_, err := session.conn.Write(make([]byte, 0, 0))
// Read of 0 bytes seems to be more reliable than write
//_, err := session.conn.Write(make([]byte, 0, 0))
//if err != nil {
// log.Printf("WS connection closed: %v", err)
// return
//}
_, err := session.conn.Read(make([]byte, 0, 0))
if err != nil {
log.Printf("WS connection closed: %v", err)
return