From 83e8dfdaf048a092534ea9da4e2e477eb38aaa34 Mon Sep 17 00:00:00 2001 From: Claudio Costa Date: Wed, 4 Dec 2024 12:01:28 -0600 Subject: [PATCH] Leave nodeID empty when using RTCD service (#912) (#914) --- server/activate.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/server/activate.go b/server/activate.go index 6b419dac..63fceffb 100644 --- a/server/activate.go +++ b/server/activate.go @@ -147,6 +147,10 @@ func (p *Plugin) OnActivate() (retErr error) { }() } + // rtcServer and rtcdManager are mutually exclusive throughout the entire lifetime of the plugin. + // Which one is used is decided here, during activation. + // We first check if RTCD is configured and allowed by the license. If so + // we try to initialize its connection and fail to start the plugin if that errors. if rtcdURL := cfg.getRTCDURL(); rtcdURL != "" && p.licenseChecker.RTCDAllowed() { rtcdManager, err := p.newRTCDClientManager(rtcdURL) if err != nil { @@ -189,15 +193,22 @@ func (p *Plugin) OnActivate() (retErr error) { return err } + // NodeID is set only when using the embedded service (no RTCD) since it's used to track which node is hosting + // a call and coordinate between nodes they may own the WS connection for other sessions in that same call. + // When RTCD is in place, there isn't a node hosting a call since this task is completely delegated to the RTCD side. + // Hence, in that case this field should be left empty. + p.nodeID = status.ClusterId + p.rtcServer = rtcServer + // The wsWriter routine is only necessary when running the embedded RTC server since + // it's a listener on rtcServer.ReceiveCh used to forward RTC messages (e.g. signaling) + // back to the client through the WS connection. The RTCD handler has a separate way to + // do this (see clientReader method). go p.wsWriter() } - p.mut.Lock() - p.nodeID = status.ClusterId - p.mut.Unlock() - + // Cluster events need to be handled regardless of whether the embedded RTC service or RTCD are in use. go p.clusterEventsHandler() p.LogDebug("activated", "ClusterID", status.ClusterId)