mirror of
https://github.com/livekit/livekit.git
synced 2026-05-25 01:35:39 +00:00
Remove STUN candidates, disconnect clients on ICE failed
This commit is contained in:
+2
-2
@@ -32,8 +32,8 @@ rtc:
|
||||
# max_bitrate: 3145728
|
||||
# # number of packets to buffer in the SFU, defaults to 500
|
||||
# packet_buffer_size: 500
|
||||
# # optional stun servers to use. by default LiveKit uses Google's public STUN servers
|
||||
# # LiveKit will automatically configure connected clients to use the same STUN servers
|
||||
# # optional STUN servers for LiveKit clients to use. Clients will be configured to use these STUN servers automatically.
|
||||
# # by default LiveKit clients use Google's public STUN servers
|
||||
# stun_servers:
|
||||
# - server1
|
||||
# # minimum amount of time between pli/fir rtcp packets being sent to an individual
|
||||
|
||||
+1
-10
@@ -2,7 +2,6 @@ package rtc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
@@ -47,15 +46,6 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
||||
loggerFactory := logging.NewDefaultLoggerFactory()
|
||||
lkLogger := loggerFactory.NewLogger("livekit-mux")
|
||||
|
||||
iceUrls := make([]string, 0)
|
||||
for _, stunServer := range rtcConf.StunServers {
|
||||
iceUrls = append(iceUrls, fmt.Sprintf("stun:%s", stunServer))
|
||||
}
|
||||
c.ICEServers = []webrtc.ICEServer{
|
||||
{
|
||||
URLs: iceUrls,
|
||||
},
|
||||
}
|
||||
if rtcConf.UseExternalIP && externalIP != "" {
|
||||
s.SetNAT1To1IPs([]string{externalIP}, webrtc.ICECandidateTypeHost)
|
||||
}
|
||||
@@ -74,6 +64,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
|
||||
var udpMux *ice.UDPMuxDefault
|
||||
var udpMuxConn *net.UDPConn
|
||||
var err error
|
||||
|
||||
if rtcConf.UDPPort != 0 {
|
||||
udpMuxConn, err = net.ListenUDP("udp4", &net.UDPAddr{
|
||||
Port: int(rtcConf.UDPPort),
|
||||
|
||||
@@ -851,7 +851,8 @@ func (p *ParticipantImpl) handlePublisherICEStateChange(state webrtc.ICEConnecti
|
||||
// "participant", p.identity)
|
||||
if state == webrtc.ICEConnectionStateConnected {
|
||||
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
||||
} else if state == webrtc.ICEConnectionStateDisconnected || state == webrtc.ICEConnectionStateFailed {
|
||||
} else if state == webrtc.ICEConnectionStateFailed {
|
||||
// only close when failed, to allow clients opportunity to reconnect
|
||||
go func() {
|
||||
_ = p.Close()
|
||||
}()
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestICEStateChange(t *testing.T) {
|
||||
p.onClose = func(participant types.Participant) {
|
||||
close(closeChan)
|
||||
}
|
||||
p.handlePublisherICEStateChange(webrtc.ICEConnectionStateDisconnected)
|
||||
p.handlePublisherICEStateChange(webrtc.ICEConnectionStateFailed)
|
||||
|
||||
select {
|
||||
case <-closeChan:
|
||||
|
||||
Reference in New Issue
Block a user