From daafc471f157ce7d62901450d42f0c30e2a85891 Mon Sep 17 00:00:00 2001 From: adwpc Date: Wed, 21 Jul 2021 09:19:40 +0800 Subject: [PATCH] (fix) fix no transport error when trickle (#573) --- docker-compose.yml | 26 +++++++++++++------------- pkg/node/sfu/server.go | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 842f14567..3a1f04003 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,19 +30,19 @@ services: networks: - ionnet - avp: - image: pionwebrtc/ion:latest-avp - build: - dockerfile: ./docker/avp.Dockerfile - context: . - volumes: - - "./configs/docker/avp.toml:/configs/avp.toml" - - "./out:/out/" - depends_on: - - nats - - islb - networks: - - ionnet + #avp: + # image: pionwebrtc/ion:latest-avp + # build: + # dockerfile: ./docker/avp.Dockerfile + # context: . + # volumes: + # - "./configs/docker/avp.toml:/configs/avp.toml" + # - "./out:/out/" + # depends_on: + # - nats + # - islb + # networks: + # - ionnet signal: image: pionwebrtc/ion:latest-signal diff --git a/pkg/node/sfu/server.go b/pkg/node/sfu/server.go index 9faf7cf0c..ee86d3734 100644 --- a/pkg/node/sfu/server.go +++ b/pkg/node/sfu/server.go @@ -49,6 +49,7 @@ func (s *sfuServer) postISLBEvent(event *islb.ISLBEvent) { } func (s *sfuServer) Signal(stream pb.SFU_SignalServer) error { + recvCandidates := []webrtc.ICECandidateInit{} peer := isfu.NewPeer(s.sfu) var streams []*ion.Stream @@ -326,20 +327,20 @@ func (s *sfuServer) Signal(stream pb.SFU_SignalServer) error { continue } + // trickle the old candidates + for _, candidate := range recvCandidates { + err = peer.Trickle(candidate, int(payload.Trickle.Target)) + if err != nil { + log.Warnf("peer trickle error: %v", err) + } + } err = peer.Trickle(candidate, int(payload.Trickle.Target)) if err != nil { switch err { case isfu.ErrNoTransportEstablished: - log.Errorf("peer hasn't joined, error -> %v", err) - err = stream.Send(&pb.SignalReply{ - Payload: &pb.SignalReply_Error{ - Error: fmt.Errorf("trickle error: %w", err).Error(), - }, - }) - if err != nil { - log.Errorf("grpc send error: %v", err) - return status.Errorf(codes.Internal, err.Error()) - } + // cadidate arrived before join, cache it + log.Infof("cadidate arrived before join, cache it: %v", candidate) + recvCandidates = append(recvCandidates, candidate) default: return status.Errorf(codes.Unknown, fmt.Sprintf("negotiate error: %v", err)) }