Do not close publisher peer connection to aid migration. (#4427)

This commit is contained in:
Raja Subramanian
2026-04-03 21:50:59 +05:30
committed by GitHub
parent 91e90c1020
commit 8a67dd1b9f
4 changed files with 33 additions and 22 deletions
+2 -2
View File
@@ -1513,7 +1513,7 @@ func (p *ParticipantImpl) setupMigrationTimerLocked() {
if p.IsClosed() || p.IsDisconnected() { if p.IsClosed() || p.IsDisconnected() {
return return
} }
p.subLogger.Debugw("closing peer connection(s) to aid migration") p.subLogger.Debugw("closing subscriber peer connection to aid migration")
// //
// Close all down tracks before closing subscriber peer connection. // Close all down tracks before closing subscriber peer connection.
@@ -1523,7 +1523,7 @@ func (p *ParticipantImpl) setupMigrationTimerLocked() {
// //
p.SubscriptionManager.Close(true) p.SubscriptionManager.Close(true)
p.TransportManager.Close() p.TransportManager.SubscriberClose()
}) })
} }
+25 -19
View File
@@ -53,7 +53,19 @@ func (s *signallerAsync) WriteMessage(msg proto.Message) error {
return nil return nil
} }
getMessageType := func(msg proto.Message) string {
messageType := "unknown"
if typed, ok := msg.(*livekit.SignalResponse); ok {
messageType = fmt.Sprintf("%T", typed.Message)
}
return messageType
}
if s.params.Participant.IsDisconnected() { if s.params.Participant.IsDisconnected() {
s.params.Logger.Debugw(
"counld not send message to participant, participant disconnected",
"messageType", getMessageType(msg),
)
return nil return nil
} }
@@ -72,33 +84,27 @@ func (s *signallerAsync) WriteMessage(msg proto.Message) error {
sink := s.GetResponseSink() sink := s.GetResponseSink()
if sink == nil { if sink == nil {
if typed, ok := msg.(*livekit.SignalResponse); ok { s.params.Logger.Debugw(
s.params.Logger.Debugw( "could not send message to participant, no sink",
"could not send message to participant", "messageType", getMessageType(msg),
"messageType", fmt.Sprintf("%T", typed.Message), )
)
}
return nil return nil
} }
err := sink.WriteMessage(msg) err := sink.WriteMessage(msg)
if err != nil { if err != nil {
if utils.ErrorIsOneOf(err, psrpc.Canceled, routing.ErrChannelClosed) { if utils.ErrorIsOneOf(err, psrpc.Canceled, routing.ErrChannelClosed) {
if typed, ok := msg.(*livekit.SignalResponse); ok { s.params.Logger.Debugw(
s.params.Logger.Debugw( "could not send message to participant",
"could not send message to participant", "error", err,
"error", err, "messageType", getMessageType(msg),
"messageType", fmt.Sprintf("%T", typed.Message), )
)
}
return nil return nil
} else { } else {
if typed, ok := msg.(*livekit.SignalResponse); ok { s.params.Logger.Warnw(
s.params.Logger.Warnw( "could not send message to participant", err,
"could not send message to participant", err, "messageType", getMessageType(msg),
"messageType", fmt.Sprintf("%T", typed.Message), )
)
}
return err return err
} }
} else { } else {
+4
View File
@@ -211,6 +211,10 @@ func (t *TransportManager) Close() {
} }
} }
func (t *TransportManager) SubscriberClose() {
t.subscriber.Close()
}
func (t *TransportManager) HasPublisherEverConnected() bool { func (t *TransportManager) HasPublisherEverConnected() bool {
return t.publisher.HasEverConnected() return t.publisher.HasEverConnected()
} }
+2 -1
View File
@@ -335,7 +335,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
roomName, pi, code, err = s.validateInternal(pLogger, r, needsJoinRequest, false) roomName, pi, code, err = s.validateInternal(pLogger, r, needsJoinRequest, false)
if err != nil { if err != nil {
HandleError(w, r, code, err) HandleError(w, r, code, err, getLoggerFields()...)
return return
} }
@@ -343,6 +343,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
if pi.ID != "" { if pi.ID != "" {
pID = pi.ID pID = pi.ID
} }
pLogger.Debugw("join request validated", append(getLoggerFields(), "participantInit", &pi))
// give it a few attempts to start session // give it a few attempts to start session
var cr connectionResult var cr connectionResult