the read call to check for connectivity was doing more harm than good. Removed it. In the end there were situations where the read was blocking indefinitely, finally leading to a deadlock situation.

This commit is contained in:
Erik Brakkee 2024-08-10 13:01:40 +02:00
parent 7c387d5bb4
commit ffcf7c8599

View File

@ -71,8 +71,6 @@ func GetUserLocation(r *http.Request) (*time.Location, error) {
}
func (session *WebSession) WriteNotifications(location *time.Location) {
timer := time.NewTicker(10 * time.Second)
defer timer.Stop()
for {
select {
case notification, ok := <-session.notifications:
@ -85,18 +83,6 @@ func (session *WebSession) WriteNotifications(location *time.Location) {
log.Printf("WS connection closed: %v", err)
return
}
case <-timer.C:
// 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
}
}
}
}