Skip to content

Commit c4b9610

Browse files
committed
hotfix: mqtt webrtc - wrong session key
1 parent 6a44498 commit c4b9610

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

machinery/src/routers/mqtt/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,12 @@ func HandleReceiveHDCandidates(mqttClient mqtt.Client, hubKey string, payload mo
457457

458458
if receiveHDCandidatesPayload.Timestamp != 0 {
459459
if communication.CameraConnected {
460-
channel := webrtc.CandidateArrays[receiveHDCandidatesPayload.SessionID]
460+
key := configuration.Config.Key + "/" + receiveHDCandidatesPayload.SessionID
461+
channel := webrtc.CandidateArrays[key]
462+
if channel == nil {
463+
channel = make(chan string)
464+
webrtc.CandidateArrays[key] = channel
465+
}
461466
log.Log.Info("HandleReceiveHDCandidates: " + receiveHDCandidatesPayload.Candidate)
462467
channel <- receiveHDCandidatesPayload.Candidate
463468
} else {

machinery/src/webrtc/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
125125
Credential: w.TurnServersCredential,
126126
},
127127
},
128+
ICETransportPolicy: pionWebRTC.ICETransportPolicyRelay,
128129
},
129130
)
130131

@@ -215,7 +216,7 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
215216
payload, err := models.PackageMQTTMessage(configuration, message)
216217
if err == nil {
217218
log.Log.Info("InitializeWebRTCConnection:" + string(candateBinary))
218-
token := mqttClient.Publish("kerberos/hub/"+hubKey, 0, false, payload)
219+
token := mqttClient.Publish("kerberos/hub/"+hubKey, 2, false, payload)
219220
token.Wait()
220221
} else {
221222
log.Log.Info("HandleRequestConfig: something went wrong while sending acknowledge config to hub: " + string(payload))
@@ -241,7 +242,7 @@ func InitializeWebRTCConnection(configuration *models.Configuration, communicati
241242
}
242243
payload, err := models.PackageMQTTMessage(configuration, message)
243244
if err == nil {
244-
token := mqttClient.Publish("kerberos/hub/"+hubKey, 0, false, payload)
245+
token := mqttClient.Publish("kerberos/hub/"+hubKey, 2, false, payload)
245246
token.Wait()
246247
} else {
247248
log.Log.Info("HandleRequestConfig: something went wrong while sending acknowledge config to hub: " + string(payload))

0 commit comments

Comments
 (0)