Skip to content

Getting Unable to protect RTP: :replay_old #186

@asib

Description

@asib

Hey there! Firstly, thank you for all your work on this, I'm totally uneducated with respect to WebRTC and yet even I was able to put together a PoC.

Context

I have an app to which I'm trying to add a voice chat feature. Specifically, it's a multiplayer game where I want it to be possible for all players to send and receive audio. I'm essentially copying the two components in live_ex_webrtc and stripping out the bits related to video to do this. That is to say, the architecture is:

  • there's a publisher liveview which has a peer connection for publishing that is connected to the browser
  • the publisher liveview broadcasts packets received on that PC over pubsub
  • there's a player liveview that is subscribed to the pubsub channel, and has its own PC, connected to the browser
  • when the player liveview receives a packet via pubsub, it sends it down to the browser via its PC, using pc.send_rtp(...)
  • both these liveviews are rendered on the same page (using live_render())

The publisher PC isn't established until the user presses a button on the page to start streaming their microphone audio. They can press it again to stop streaming, by which I mean the PC is closed and all state is destroyed. If they press it a third time, the publisher PC is established completely fresh.

The player PC is established when the page is loaded, and never destroyed.

The problem

The problem I have is that in testing, I noticed that if I start/stop the publisher stream (by pressing the aforementioned button repeatedly) enough times, I eventually see the following message: Unable to protect RTP: :replay_old in the server logs, and packets stop being sent to any player PCs connected to the server. This usually happens the third time I try to start the publisher stream; not sure if that is of significance.

I put a dbg(packet) into my code just before the pc.send_rtp() call, and noticed that I see the :replay_old message only when the sequence_number field of the ExRTP.Packets is lower than it was when the previous publisher PC was disconnected. Indeed on one occasion, I just left the publisher streaming for long enough that the sequence number caught back up to where it had been previously, and the warning ceased and I could hear audio again.

I added some state to the player liveview to keep track of the last seen sequence number, and to rewrite any packets to use a sequence number one greater than the last seen, to ensure the player PC never sees a sequence number twice. This solved the problem, but it seems a bit haphazard.

So I'm wondering if I'm doing something wrong to begin with?

Appreciate any help and guidance you're able to give!

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions