steep-balloon-41261
10/06/2023, 11:28 AMdry-elephant-14928
10/06/2023, 11:29 PMdry-elephant-14928
10/06/2023, 11:29 PMboundless-jackal-7234
10/07/2023, 12:44 AMboundless-jackal-7234
10/07/2023, 12:47 AMfaint-army-19363
10/08/2023, 9:13 AM// publish reliable data to a set of participants
room.localParticipant.publishData(data, DataPacket_Kind.RELIABLE, ['participant_sid'])
• Step 2: Receive data from other particpants via RoomEvent.DataReceived event listener
// receive data from other participants
room.on(RoomEvent.DataReceived, (payload: Uint8Array, participant: Participant, kind: DataPacket_Kind) => {
const strData = decoder.decode(payload)
//log strData in console log
...
})
• In Step 2, for the one message published in Step 1 will trigger more than one trigger/event in Step 2 > console.log output
Expected behavior:
When a single message emit data via xxxx.PubishData function, it should only trigger one attempt in RoomEvent.DataReceived event listener when data is received to the client.
Actual behavior:
When a single message emit data via xxxx.PubishData function, it trigger many attempts (some time 10. sometimes 100+) in RoomEvent.DataReceived event listener when data is received to the client.
Screencap of the errors or additional context:
- source code that can be used to reproduce the code : https://github.com/udaraJ08/livekit-data-event-bug-reproduce-repo.git
- this include the latest livekit example source code ( "livekit/components-react": "^1.1.8" - https://github.com/udaraJ08/livekit-data-event-bug-reproduce-repo/blob/58fef06837fc7af7bc4ee770017957ef4b285791/package.json#L9C9-L9C9) with minimal update to reproduce the bug
• Attached screencap of the issue reproduce for your reference.
--------------------------------------------------------------------------------------------------------
We greatly appreciate you guys insights into this to sort the issue as soon as possible.faint-army-19363
10/08/2023, 9:35 AMdry-elephant-14928
10/11/2023, 12:00 AMuseEffect and suchfaint-army-19363
10/11/2023, 2:53 AMboundless-jackal-7234
10/12/2023, 9:04 AMfaint-army-19363
10/12/2023, 2:41 PMpolite-kilobyte-67570
10/16/2023, 5:59 AMboundless-jackal-7234
10/16/2023, 6:00 AMboundless-jackal-7234
10/17/2023, 1:58 AMpolite-kilobyte-67570
10/17/2023, 8:10 AMuseEffect here never unsubscribes. So whenever the effect runs again you add additional handlers.
There’s two ways to solve this:
1. Return a function in that useEffect that unsubscribes from the event
2. use the useDataChannel(onDataMessage) hook instead (recommended)boundless-jackal-7234
10/17/2023, 8:12 AMpolite-kilobyte-67570
10/17/2023, 8:12 AM