Log more peer conenction state on close timeout. (#4105)
This commit is contained in:
+25
-4
@@ -282,9 +282,10 @@ type PCTransport struct {
|
|||||||
pendingRestartIceOffer *webrtc.SessionDescription
|
pendingRestartIceOffer *webrtc.SessionDescription
|
||||||
|
|
||||||
// CLOSE-DEBUG-CLEANUP
|
// CLOSE-DEBUG-CLEANUP
|
||||||
iceGatheringState atomic.Value // webrtc.ICEGatheringState
|
iceGatheringState atomic.Value // webrtc.ICEGatheringState
|
||||||
iceConnectionState atomic.Value // webrtc.ICEConnectionState
|
iceConnectionState atomic.Value // webrtc.ICEConnectionState
|
||||||
peerConnectionState atomic.Value // webrtc.PeerConnectionState
|
iceConnectionStateChangeAt atomic.Time
|
||||||
|
peerConnectionState atomic.Value // webrtc.PeerConnectionState
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransportParams struct {
|
type TransportParams struct {
|
||||||
@@ -809,6 +810,7 @@ func (t *PCTransport) handleConnectionFailed(forceShortConn bool) {
|
|||||||
|
|
||||||
func (t *PCTransport) onICEConnectionStateChange(state webrtc.ICEConnectionState) {
|
func (t *PCTransport) onICEConnectionStateChange(state webrtc.ICEConnectionState) {
|
||||||
t.iceConnectionState.Store(state)
|
t.iceConnectionState.Store(state)
|
||||||
|
t.iceConnectionStateChangeAt.Store(time.Now())
|
||||||
t.params.Logger.Debugw("ice connection state change", "state", state.String())
|
t.params.Logger.Debugw("ice connection state change", "state", state.String())
|
||||||
switch state {
|
switch state {
|
||||||
case webrtc.ICEConnectionStateConnected:
|
case webrtc.ICEConnectionStateConnected:
|
||||||
@@ -1463,6 +1465,16 @@ func (t *PCTransport) Close() {
|
|||||||
iceStats := t.mayFailedICEStats
|
iceStats := t.mayFailedICEStats
|
||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
|
|
||||||
|
numActiveTransceivers := 0
|
||||||
|
numInactiveTransceivers := 0
|
||||||
|
for _, tr := range t.pc.GetTransceivers() {
|
||||||
|
if tr.Direction() == webrtc.RTPTransceiverDirectionInactive {
|
||||||
|
numInactiveTransceivers++
|
||||||
|
} else {
|
||||||
|
numActiveTransceivers++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t.params.Logger.Infow(
|
t.params.Logger.Infow(
|
||||||
"transport close timeout",
|
"transport close timeout",
|
||||||
"eventsQueueDone", eventsQueueDone.Load(),
|
"eventsQueueDone", eventsQueueDone.Load(),
|
||||||
@@ -1476,10 +1488,17 @@ func (t *PCTransport) Close() {
|
|||||||
"iceConnectedAt", iceConnectedAt,
|
"iceConnectedAt", iceConnectedAt,
|
||||||
"iceGatheringState", t.iceGatheringState.Load().(webrtc.ICEGatheringState).String(),
|
"iceGatheringState", t.iceGatheringState.Load().(webrtc.ICEGatheringState).String(),
|
||||||
"iceConnectionState", t.iceConnectionState.Load().(webrtc.ICEConnectionState).String(),
|
"iceConnectionState", t.iceConnectionState.Load().(webrtc.ICEConnectionState).String(),
|
||||||
|
"icceConnectionStateChangedAt", t.iceConnectionStateChangeAt.Load(),
|
||||||
"peerConnectionState", t.peerConnectionState.Load().(webrtc.PeerConnectionState).String(),
|
"peerConnectionState", t.peerConnectionState.Load().(webrtc.PeerConnectionState).String(),
|
||||||
|
"signalingState", t.pc.SignalingState().String(),
|
||||||
"iceStats", iceCandidatePairStatsEncoder{iceStats},
|
"iceStats", iceCandidatePairStatsEncoder{iceStats},
|
||||||
"iceConnectionInfo", t.GetICEConnectionInfo(),
|
"iceConnectionInfo", t.GetICEConnectionInfo(),
|
||||||
"connectionType", t.connectionDetails.GetConnectionType(),
|
"connectionType", t.connectionDetails.GetConnectionType(),
|
||||||
|
"sctpTransportState", t.pc.SCTP().State().String(),
|
||||||
|
"dltsTransportState", t.pc.SCTP().Transport().State().String(),
|
||||||
|
"iceTransportState", t.iceTransport.State().String(),
|
||||||
|
"numInactiveTransceivers", numInactiveTransceivers,
|
||||||
|
"numActiveTransceivers", numActiveTransceivers,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1524,7 +1543,9 @@ func (t *PCTransport) Close() {
|
|||||||
unlabeledDataChannelClosed.Store(true)
|
unlabeledDataChannelClosed.Store(true)
|
||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
|
|
||||||
_ = t.pc.Close()
|
if err := t.pc.Close(); err != nil {
|
||||||
|
t.params.Logger.Warnw("unclean close of peer connection", err)
|
||||||
|
}
|
||||||
peerConnectionClosed.Store(true)
|
peerConnectionClosed.Store(true)
|
||||||
|
|
||||||
t.outputAndClearICEStats()
|
t.outputAndClearICEStats()
|
||||||
|
|||||||
Reference in New Issue
Block a user