Hi Gbenga,
though you did not share your full script, one thing that catched my eyes
is that $avp(modifiedSDP) is never set (you have $avp(originalSDP)
though...)
ex:
$avp(originalSDP) = $rb;
...
set_body("$avp(modifiedSDP)","application/sdp");
I would check that 1st.
Other than that, as far as I know, rtpengine_manage() modifies the SDP by
itself, I don't think you would need a call to set_body().
Remove those lines and add something like:
if (sdp_content()) {
$avp(originalSDP) = $rb;
}
Also, you might want to use the direction parameters for RTPEngine, as it
will tell RTPEngine that the first leg uses interface X and the second leg
uses interface Y.
Something like:
rtpengine_manage("... direction=external direction=internal");
You might also want to check the condition in route[SET_RTP_REPLY] :
if(isflagset(FLB_FROM_CORE_TO_WEBRTC)) {
xlog("L_INFO", "SET_RTP_REPLY | FROM CORE TO WEBRTC");
rtpengine_manage("replace-origin replace-session-connection RTP/SAVPF
ICE=remove ...");
}
When sending a reply to WebRTC Client, use ICE=force instead of ICE=remove
to force RTPEngine to generate the correct ICE candidates/flags with the
external IP address.
Hope this helps.
Atenciosamente / Kind Regards / Cordialement / Un saludo,
*Sérgio Charrua*
*www.kahea.ai <http://www.kahea.ai> / www.voip.pt <http://www.voip.pt>*
*OpenTelecom* - Consulting for Telecoms, Lda
Tel.: +351 <callto:+351+91+104+12+66>91 631 11 44
Email : *[email protected] <[email protected]>*
This message and any files or documents attached are strictly confidential
or otherwise legally protected.
It is intended only for the individual or entity named. If you are not the
named addressee or have received this email in error, please inform the
sender immediately, delete it from your system and do not copy or disclose
it or its contents or use it for any purpose. Please also note that
transmission cannot be guaranteed to be secure or error-free.
On Mon, Feb 2, 2026 at 3:59 PM Gbenga Daramola via sr-users <
[email protected]> wrote:
> Hello,
> I need assistance with my kamailio, RTPEngine and Freeswitch
> implementation with WEBRTC. I am using a cloud instance with a private IP
> and a 1:1 NAT Public IP. I have setup the internal and external RTPEngine
> config
> interface = internal/192.168.xx.xx;external/ 192.168.xx.xx!8X.XXX.XXX.XXX
> For my normal SIP to SIP implementation, my SIP signaling and RTP traffic
> goes fine and I get to have two way audio. but for Webrtc in the SDP reply
> to my public webrtc client, I get to see the private IP in the client
> response if I force ICE, thus causing no audio negotiation since the public
> IP can't reach the private IP.
> I have been troubleshooting this, I am beginning to think I am doing it
> wrong. Please has anyone implemented this or something similar. I need to
> make this work and I have limited time.
> Could I also get the best method for detecting WebRTC reply and response
> in order to set the right RTPmanage flags as this is also a major issue.
> Below is a snippet of my config.
>
> route[SET_DIRECTION_FLAG] {
>
> if (is_in_subnet("$si", "192.168.0.0/16")) {
>
> if ($proto == "WS" || $proto == "WSS" || $ru =~
> "transport=(ws|wss)") {
> xlog("L_INFO", "[DIR] CORE → WEBRTC | src=$si proto=$proto
> ru=$ru\n");
> setflag(FLB_FROM_CORE_TO_WEBRTC);
> return;
> }
>
> xlog("L_INFO", "[DIR] CORE → SIP | src=$si proto=$proto ru=$ru\n");
> setflag(FLB_FROM_CORE_TO_SIP);
> return;
> }
>
> else {
>
> # Public → WebRTC
> if ($proto == "WS" || $proto == "WSS") {
> xlog("L_INFO", "[DIR] PUBLIC → WEBRTC | src=$si proto=$proto
> ru=$ru\n");
> setflag(FLB_FROM_PUBLIC_FROM_WEBRTC);
> return;
> }
>
> # Public → SIP
> xlog("L_INFO", "[DIR] PUBLIC → SIP | src=$si proto=$proto
> ru=$ru\n");
> setflag(FLB_FROM_PUBLIC_FROM_SIP);
> return;
> }
> }
>
> route[SET_RTP_REQUEST] {
> if (!is_method("UPDATE|INVITE")) {
> return 0;
> }
>
> if (sdp_content()) {
> $avp(originalSDP) = $rb;
> if(isflagset(FLB_FROM_PUBLIC_FROM_WEBRTC)) {
> xlog("L_INFO", "SET_RTP_REQUEST | FROM PUBLIC FROM
> WEBRTC");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP ICE=remove direction=external
> direction=internal");
> }
> if(isflagset(FLB_FROM_PUBLIC_FROM_SIP)) {
> xlog("L_INFO", "SET_RTP_REQUEST | FROM PUBLIC FROM
> SIP");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP ICE=remove direction=external
> direction=internal");
> }
> if(isflagset(FLB_FROM_CORE_TO_WEBRTC)) {
> xlog("L_INFO", "SET_RTP_REQUEST | FROM CORE TO
> WEBRTC");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/SAVPF ICE=force direction=internal
> direction=external");
> }
> if(isflagset(FLB_FROM_CORE_TO_SIP)) {
> xlog("L_INFO", "SET_RTP_REQUEST | FROM CORE TO
> SIP");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP ICE=remove direction=internal
> direction=external");
> }
> set_body("$avp(modifiedSDP)","application/sdp");
> }
> }
>
> route[SET_RTP_REPLY] {
> xlog("L_INFO", "SET_RTP_REPLY | ENTERING THE ROUTE BLOCK");
>
> if (sdp_content()) {
> $avp(originalSDP) = $rb;
> if(isflagset(FLB_FROM_PUBLIC_FROM_WEBRTC)) {
> xlog("L_INFO", "SET_RTP_REPLY | FROM PUBLIC FROM
> WEBRTC");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP ICE=remove direction=external
> direction=internal");
> }
> if(isflagset(FLB_FROM_PUBLIC_FROM_SIP)) {
> xlog("L_INFO", "SET_RTP_REPLY | FROM PUBLIC FROM
> SIP");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP ICE=remove direction=external
> direction=internal");
> }
> if(isflagset(FLB_FROM_CORE_TO_WEBRTC)) {
> xlog("L_INFO", "SET_RTP_REPLY | FROM CORE TO
> WEBRTC");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/SAVPF ICE=remove direction=internal
> direction=external");
> }
> if(isflagset(FLB_FROM_CORE_TO_SIP)) {
> xlog("L_INFO", "SET_RTP_REPLY | FROM CORE TO SIP");
> rtpengine_manage("replace-origin
> replace-session-connection RTP/AVP direction=internal direction=external");
> }
> set_body("$avp(modifiedSDP)","application/sdp");
> }
>
> if ($rs=~"[3-6][0-9][0-9]") {
> rtpengine_manage();
> }
> }
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions --
> [email protected]
> To unsubscribe send an email to [email protected]
> Important: keep the mailing list in the recipients, do not reply only to
> the sender!
>
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions --
[email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!