livekit icon indicating copy to clipboard operation
livekit copied to clipboard

Data Channel Delay in Receiving Data after OnParticipantConnected Event Trigger

Open MykolaSolyanko opened this issue 2 years ago • 2 comments

Describe the bug The bug occurs when trying to send data to a new participant in a room using the OnParticipantConnected callback. Occasionally, the new participant does not receive data sent through the channel when using r.room.LocalParticipant.PublishData(data, livekit.DataPacket_RELIABLE, participantSID). This issue is mitigated by adding a timeout of at least one second before sending data. It appears that receiving the OnParticipantConnected event does not ensure that the remote participant is ready to receive data, video, or audio. When data is sent after some time following this event, it operates as expected.

Server

  • Version: 1.4.4
  • Environment: local dev
  • Additional info: Local Redis is being used.

Client

  • SDK: server-sdk-go
  • Version: 1.0.16

To Reproduce Steps to reproduce the behavior:

  1. Create a room and attach an OnParticipantConnected callback.
  2. Upon the trigger of OnParticipantConnected, attempt to send data to the remote participant through the data channel.
  3. Observe that the new participant does not always receive this data.
  4. Introducing a timeout of at least one second before sending seems to circumvent this issue.

Expected behavior The expected behavior is that, when the OnParticipantConnected callback is invoked, the remote participant should be ready to receive data without any added delays or timeouts on the application's side.

Additional context This bug may stem from the potential delay between the OnParticipantConnected event and the participant’s actual readiness to receive data. Therefore, a reliable event or indicator signifying the complete readiness of the participant to receive data, audio, or video is needed. The workaround is to send data after a certain delay post-event, which works flawlessly.

MykolaSolyanko avatar Sep 25 '23 05:09 MykolaSolyanko

@MykolaSolyanko you are absolutely right this is an issue for us. we are currently looking at a few options on removing this initial delivery gap.

davidzhao avatar Sep 27 '23 00:09 davidzhao

@davidzhao Hi. Any progress on this? I try to publish a local .ogg audio track when OnParticipantConnected is fired and get 0-5 seconds of the audio file missing on the listener's side regardless of delay after OnParticipantConnected and publishing (like 15s delay doesn't help). Everything works locally on my local network. It's the essential thing for my use-case of streaming voice messages.

denis-obukhov avatar Mar 29 '24 03:03 denis-obukhov