From aa3fe7c6a3842abb303749809366272c4034eb73 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Mon, 6 Jan 2020 12:40:28 -0800 Subject: [PATCH] Add error message when no pairs Add error message if pingAllCandidates is called and we have no candidate pairs. This may help users when debugging. --- agent.go | 6 ++++++ selection.go | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/agent.go b/agent.go index 075a2c4..f163389 100644 --- a/agent.go +++ b/agent.go @@ -654,6 +654,12 @@ func (a *Agent) setSelectedPair(p *candidatePair) { } func (a *Agent) pingAllCandidates() { + a.log.Trace("pinging all candidates") + + if len(a.checklist) == 0 { + a.log.Warn("pingAllCandidates called with no candidate pairs. Connection is not possible yet.") + } + for _, p := range a.checklist { if p.state == CandidatePairStateWaiting { p.state = CandidatePairStateInProgress diff --git a/selection.go b/selection.go index a8e718b..9cbe6c0 100644 --- a/selection.go +++ b/selection.go @@ -92,8 +92,6 @@ func (s *controllingSelector) ContactCandidates() { s.nominatePair(p) return } - - s.log.Trace("pinging all candidates") s.agent.pingAllCandidates() } } @@ -215,7 +213,6 @@ func (s *controlledSelector) ContactCandidates() { s.log.Trace("check timeout reached and no valid candidate pair found, marking connection as failed") s.agent.updateConnectionState(ConnectionStateFailed) } else { - s.log.Trace("pinging all candidates") s.agent.pingAllCandidates() } }