diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 92723d606..baf1a2db4 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -502,6 +502,7 @@ func (conn *Conn) onRelayDisconnected() { if err := conn.removeWgPeer(); err != nil { conn.log.Errorf("failed to remove wg endpoint: %v", err) } + conn.currentConnPriority = connPriorityNone } if conn.wgProxyRelay != nil { diff --git a/client/internal/peer/worker_ice.go b/client/internal/peer/worker_ice.go index 5ceb3f453..4ff13b455 100644 --- a/client/internal/peer/worker_ice.go +++ b/client/internal/peer/worker_ice.go @@ -65,6 +65,7 @@ func NewWorkerICE(ctx context.Context, log *log.Entry, config ConnConfig, conn * iFaceDiscover: ifaceDiscover, statusRecorder: statusRecorder, hasRelayOnLocally: hasRelayOnLocally, + lastKnownState: ice.ConnectionStateDisconnected, } localUfrag, localPwd, err := icemaker.GenerateICECredentials() @@ -213,7 +214,7 @@ func (w *WorkerICE) reCreateAgent(agentCancel context.CancelFunc, candidates []i w.lastKnownState = ice.ConnectionStateConnected return case ice.ConnectionStateFailed, ice.ConnectionStateDisconnected: - if w.lastKnownState != ice.ConnectionStateDisconnected { + if w.lastKnownState == ice.ConnectionStateConnected { w.lastKnownState = ice.ConnectionStateDisconnected w.conn.onICEStateDisconnected() }