<div dir="ltr">For anyone who comes across this post in future - this is a bug in 3.1 and above (probably when topology hiding is used) which seems to have been fixed in 3.4<div>A workaround is to keep the SDP from caller or callee and send it as the third variable of media_exchange_from_uri function to establish the connection correctly.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Sep 7, 2025 at 8:34 PM M S <<a href="mailto:medeanwz@gmail.com">medeanwz@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>A(caller) <=> B(opensips) <=> C(callee)</div><div> B(opensips) <=> D(media server)</div><div><br></div><div dir="ltr">I tried it with the "callee" leg in media_exchange_from_uri too. technically, the B machine in the middle should send the ip/port of A and D to each other in SDPs to make sure media is direct between A and D - but B to D invite always has the B's ip/port in it. It should be due to something in my script, but what could it be?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 7, 2025 at 7:03 PM M S <<a href="mailto:medeanwz@gmail.com" target="_blank">medeanwz@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi list,<div>I am trying to use media_exchange_from_uri to play hold music. I use the sample code from opensips blog:</div><div><br></div><div><pre><code>if (has_totag() && is_method("INVITE")) {
# catch the on-hold re-invite
if(is_audio_on_hold()) {
if (media_exchange_from_uri("sip:moh@media.server.ip"))
exit;
} else {
# call has resumed - terminate any ongoing media played
media_terminate();
}
}</code></pre><pre><code><br></code></pre><pre>But the behaviour is strange. </pre><pre>A invite comes to proxy B, rtpproxy is engaged and invite is sent to C</pre><pre>A,Aport <=> B,Bport1 - B,Bport2 <=> C,Cport</pre><pre>A pressing hold: Invite with a=sendonly is received. With the above configuration, B sends an INVITE (B ip and Bport1) to media.server.ip (D).</pre><pre>Media server D responds with 200 OK (D ip and Dport). Opensips B2B sends D,Dport SDP to C (so C expects to receive RTP from D port).</pre><pre>While C expects to receive RTP from D directly, D has exchanged SDP with B and therefore sends RTP to B!</pre><pre>Why is this happening?</pre><pre><br></pre><pre>Thank you :)</pre></div></div></div></div>
</blockquote></div>
</blockquote></div>