Pass error details and timeouts. (#3402)

This commit is contained in:
Denys Smirnov
2025-02-06 13:53:44 +02:00
committed by GitHub
parent d8e325d3d4
commit ccbc988824
4 changed files with 19 additions and 11 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ require (
github.com/jxskiss/base62 v1.1.0 github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564 github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564
github.com/livekit/protocol v1.32.2-0.20250206022155-07992dd19e2c github.com/livekit/protocol v1.32.2-0.20250206110518-331f97dbf4f3
github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff
github.com/mackerelio/go-osstat v0.2.5 github.com/mackerelio/go-osstat v0.2.5
github.com/magefile/mage v1.15.0 github.com/magefile/mage v1.15.0
+1
View File
@@ -171,6 +171,7 @@ github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564 h1:GX7K
github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY= github.com/livekit/mediatransportutil v0.0.0-20241220010243-a2bdee945564/go.mod h1:36s+wwmU3O40IAhE+MjBWP3W71QRiEE9SfooSBvtBqY=
github.com/livekit/protocol v1.32.2-0.20250206022155-07992dd19e2c h1:zBpzvlKkqShdd+9LFTl4H2ELV6is+K/XCRIsuphfJ+w= github.com/livekit/protocol v1.32.2-0.20250206022155-07992dd19e2c h1:zBpzvlKkqShdd+9LFTl4H2ELV6is+K/XCRIsuphfJ+w=
github.com/livekit/protocol v1.32.2-0.20250206022155-07992dd19e2c/go.mod h1:9PQOu9w06M+14UDIhbmPeRRti5N4kq6n3R5XHDCzN5k= github.com/livekit/protocol v1.32.2-0.20250206022155-07992dd19e2c/go.mod h1:9PQOu9w06M+14UDIhbmPeRRti5N4kq6n3R5XHDCzN5k=
github.com/livekit/protocol v1.32.2-0.20250206110518-331f97dbf4f3/go.mod h1:68cVVExsPKEPBOzOyzhvGZbbn/+mIAGtAPYZ/+dWtRc=
github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff h1:1P84qlSggoKa60H20mAUXUkzjckHGl172ilzg5OJkho= github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff h1:1P84qlSggoKa60H20mAUXUkzjckHGl172ilzg5OJkho=
github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff/go.mod h1:X5WtEZ7OnEs72Fi5/J+i0on3964F1aynQpCalcgMqRo= github.com/livekit/psrpc v0.6.1-0.20250204212339-6de8b05bfcff/go.mod h1:X5WtEZ7OnEs72Fi5/J+i0on3964F1aynQpCalcgMqRo=
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o= github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
+13 -8
View File
@@ -35,12 +35,14 @@ import (
"go.uber.org/atomic" "go.uber.org/atomic"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/version"
"github.com/livekit/protocol/auth" "github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils/xtwirp"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/version"
) )
type LivekitServer struct { type LivekitServer struct {
@@ -114,6 +116,9 @@ func NewLivekitServer(conf *config.Config,
TwirpRequestStatusReporter(), TwirpRequestStatusReporter(),
)), )),
} }
for _, opt := range xtwirp.DefaultServerOptions() {
serverOptions = append(serverOptions, opt)
}
roomServer := livekit.NewRoomServiceServer(roomService, serverOptions...) roomServer := livekit.NewRoomServiceServer(roomService, serverOptions...)
agentDispatchServer := livekit.NewAgentDispatchServiceServer(agentDispatchService, serverOptions...) agentDispatchServer := livekit.NewAgentDispatchServiceServer(agentDispatchService, serverOptions...)
egressServer := livekit.NewEgressServer(egressService, serverOptions...) egressServer := livekit.NewEgressServer(egressService, serverOptions...)
@@ -128,11 +133,11 @@ func NewLivekitServer(conf *config.Config,
mux.HandleFunc("/debug/rooms", s.debugInfo) mux.HandleFunc("/debug/rooms", s.debugInfo)
} }
mux.Handle(roomServer.PathPrefix(), roomServer) xtwirp.RegisterServer(mux, roomServer)
mux.Handle(agentDispatchServer.PathPrefix(), agentDispatchServer) xtwirp.RegisterServer(mux, agentDispatchServer)
mux.Handle(egressServer.PathPrefix(), egressServer) xtwirp.RegisterServer(mux, egressServer)
mux.Handle(ingressServer.PathPrefix(), ingressServer) xtwirp.RegisterServer(mux, ingressServer)
mux.Handle(sipServer.PathPrefix(), sipServer) xtwirp.RegisterServer(mux, sipServer)
mux.Handle("/rtc", rtcService) mux.Handle("/rtc", rtcService)
rtcService.SetupRoutes(mux) rtcService.SetupRoutes(mux)
mux.Handle("/agent", agentService) mux.Handle("/agent", agentService)
+4 -2
View File
@@ -438,8 +438,10 @@ func (s *SIPService) CreateSIPParticipant(ctx context.Context, req *livekit.Crea
// CreateSIPParticipant will wait for LiveKit Participant to be created and that can take some time. // CreateSIPParticipant will wait for LiveKit Participant to be created and that can take some time.
// Thus, we must set a higher deadline for it, if it's not set already. // Thus, we must set a higher deadline for it, if it's not set already.
// TODO: support context timeouts in psrpc
timeout := 30 * time.Second timeout := 30 * time.Second
if req.WaitUntilAnswered {
timeout = 80 * time.Second
}
if deadline, ok := ctx.Deadline(); ok { if deadline, ok := ctx.Deadline(); ok {
timeout = time.Until(deadline) timeout = time.Until(deadline)
} else { } else {
@@ -449,7 +451,7 @@ func (s *SIPService) CreateSIPParticipant(ctx context.Context, req *livekit.Crea
} }
resp, err := s.psrpcClient.CreateSIPParticipant(ctx, "", ireq, psrpc.WithRequestTimeout(timeout)) resp, err := s.psrpcClient.CreateSIPParticipant(ctx, "", ireq, psrpc.WithRequestTimeout(timeout))
if err != nil { if err != nil {
unlikelyLogger.Errorw("cannot update sip participant", err) unlikelyLogger.Errorw("cannot create sip participant", err)
return nil, err return nil, err
} }
return &livekit.SIPParticipantInfo{ return &livekit.SIPParticipantInfo{