PJSIP keep alive vs comfort noise

Hi all,

I think this subject may have been covered a few times but was hoping to get some clarity on keep alive, comfort noise and how they work in Asterisk with PJSIP.

For some quick background we are using v18.16.0, and sometimes our calls are dropped by PSTN carriers - this is generally with onward carriers rather than those which we trunk with, so getting any changes downstream is problematic. In the calls which are bridged party A is sending constant RTP whereas party B sends nothing when there is silence / local mute.

From what I have read the channel driver being a 3rd party is in control of comfort noise, so we would need to enable (or add) CN to PJSIP itself. Has anyone ever done this, and what does it entail exactly, is it changing the source code in PJSIP and/or Asterisk and then building from source again?

What does the PJSIP entry rtp_keepalive do?
From this source, it looks like comfort noise PJSIP_ENDPOINT - Asterisk Documentation
But from this source it sounds more like when the lines are not connected https://github.com/asterisk/asterisk/blob/master/configs/samples/pjsip.conf.sample

When running a trace and with the keep alive set to 1 second I only ever see 1 CN packet, is this because after the lines are connected and party A is sending RTP fine its classed as ‘flowing’?

Any advice greatly appreciated!
Many thanks :slight_smile:

Yes. It’s only if no RTP is being sent that keepalive will trigger.

Thanks for getting back, are there any options for timeouts which would then see it as not flowing?

In my examples we only ever see one RTP packet, so is this linked to the connect line state somehow rather than flowing RTP?

Kind regards

It’s linked to outbound flowing RTP. If RTP is being sent for some reason, then keepalive would not kick in. The implementation itself is pretty small[1].

[1] https://github.com/asterisk/asterisk/blob/master/res/res_pjsip_sdp_rtp.c#L71

Thanks, this makes sense now.

After seeing the code and searching why it was not working still I found this bug [bug]: RTP keepalive logic error when RTCP is on separate port - at least needs documentation improvement · Issue #359 · asterisk/asterisk · GitHub which is the reason. Now setting the interval on both parties to 1 (less than the rtcpinterval) I can see a CN every second.

My previous setting were
PSTN endpoint conf = 30s keep alive
Other endpoint conf = 1s keep alive

But as you said its on the outbound, which for my issue is to the PSTN, and the 30s never generated the CN. So all working now :slight_smile:

Thanks again for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.