Skip to content

Commit 00b2310

Browse files
authored
delay deregister whip rpc handle to avoid sfu notify warning (#373)
1 parent 04721b5 commit 00b2310

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/whip/whip_proxy_handler.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"net/http"
2323
"net/url"
2424
"strings"
25+
"time"
2526

2627
"github.com/frostbyte73/core"
2728
"github.com/livekit/protocol/livekit"
@@ -184,7 +185,12 @@ func (h *proxyWhipHandler) close(isRTCClosed bool) {
184185

185186
utils.DeregisterIngressRpcHandlers(h.rpcServer, h.params.IngressInfo)
186187
if h.participantID != "" {
187-
h.rpcServer.DeregisterWHIPRTCConnectionNotifyTopic(h.participantID)
188+
if isRTCClosed {
189+
h.rpcServer.DeregisterWHIPRTCConnectionNotifyTopic(h.participantID)
190+
} else {
191+
// wait a bit before deregistering, in case sfu would send rtc closed notify
192+
time.AfterFunc(5*time.Second, func() { h.rpcServer.DeregisterWHIPRTCConnectionNotifyTopic(h.participantID) })
193+
}
188194
}
189195

190196
h.logger.Infow("closing WHIP session", "location", h.location, "isRTCClosed", isRTCClosed)

0 commit comments

Comments
 (0)