Do not accept websocket connection if response not received (#923)

When the instance handling the signal request did not respond to the
initial connection, we will fail the connection attempt instead of
having it hang forever.
This commit is contained in:
David Zhao
2022-08-16 19:57:41 -07:00
committed by GitHub
parent 3f53dea223
commit d9059f4f3b
3 changed files with 65 additions and 17 deletions
+4 -4
View File
@@ -7,11 +7,11 @@ import (
"github.com/livekit/protocol/logger"
)
func handleError(w http.ResponseWriter, status int, msg string) {
// GetLogger already with extra depth 1
logger.GetLogger().V(1).Info("error handling request", "error", msg, "status", status)
func handleError(w http.ResponseWriter, status int, err error, keysAndValues ...interface{}) {
keysAndValues = append(keysAndValues, "status", status)
logger.Warnw("error handling request", err, keysAndValues...)
w.WriteHeader(status)
_, _ = w.Write([]byte(msg))
_, _ = w.Write([]byte(err.Error()))
}
func boolValue(s string) bool {