fixed deadlock when client disconnecting

This commit is contained in:
David Zhao
2020-12-05 22:20:13 -08:00
parent 71a7914eec
commit 2b9fee45c4
4 changed files with 30 additions and 12 deletions
+10 -4
View File
@@ -2,6 +2,7 @@ package service
import (
"encoding/json"
"io"
"net/http"
"github.com/gorilla/websocket"
@@ -95,11 +96,16 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
//ctx := context.Background()
for {
req, err := signalConn.ReadRequest()
if err == io.EOF {
// client disconnected from websocket
return
}
if err != nil {
logger.GetLogger().Errorw("error reading WS",
"err", err,
"participantName", pName,
"roomId", roomId)
// most of these are disconnection, just return vs clogging up logs
//logger.GetLogger().Errorw("error reading WS",
// "err", err,
// "participantName", pName,
// "roomId", roomId)
return
}