<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have a working OpenSIPS deployment running as a PSTN proxy and am trying to add in support for WebRTC which will forward requests to an internal SIP PBX. Currently the registrations appear to be passing through the mid_registrar correctly and the initial
invite from my PBX is correctly routed to the websocket client.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The PBX receives messages up to the 180 ringing correctly, but on the 200 OK from the websocket client the r.uri contains a d.id rather than the ctid, this then results in the calling timing out and the ACK from the PBX not routing to the websocket client.
I believe this is the script area that is falling over once the has_totag function is checked.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>if (loose_route()) <br>
</span>
<div> {<br>
</div>
<div> if (is_method("INVITE")) <br>
</div>
<div> {<br>
</div>
<div> # even if in most of the cases is useless, do RR for<br>
</div>
<div> # re-INVITEs alos, as some buggy clients do change route set<br>
</div>
<div> # during the dialog.<br>
</div>
<div> record_route();<br>
</div>
<div> } <br>
</div>
<div> else if (is_method("ACK")) <br>
</div>
<div> {<br>
</div>
<div> if (has_body("application/sdp")) <br>
</div>
<div> {<br>
</div>
<div> # check if destination is WS<br>
</div>
<div> if ($du != NULL)<br>
</div>
<div> $var(proto) = $dP;<br>
</div>
<div> else<br>
</div>
<div> $var(proto) = $rP;<br>
</div>
<div> if ($var(proto) == "WS" || $var(proto) == "WSS")<br>
</div>
<div> setbflag(DST_WS);<br>
</div>
<div><br>
</div>
<div> route(rtpengine_answer);<br>
</div>
<div> }<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<div> # route it out to whatever destination was set by loose_route()<br>
</div>
<div> # in $du (destination URI).<br>
</div>
<div> route(websocket);<br>
</div>
<div> } <br>
</div>
<div> else <br>
</div>
<div> {<br>
</div>
<div> if ( is_method("ACK") ) <br>
</div>
<div> {<br>
</div>
<div> if ( t_check_trans() ) <br>
</div>
<div> {<br>
</div>
<div> # non loose-route, but stateful ACK; must be an ACK after<br>
</div>
<div> # a 487 or e.g. 404 from upstream server<br>
</div>
<div> t_relay();<br>
</div>
<div> exit;<br>
</div>
<div> } <br>
</div>
<div> else <br>
</div>
<div> {<br>
</div>
<div> # ACK without matching transaction -><br>
</div>
<div> # ignore and discard<br>
</div>
<div> exit;<br>
</div>
<div> }<br>
</div>
<div> }<br>
</div>
<span> sl_send_reply("404","Not here");</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The route[websocket] is using force send socket to remove the NAT address that cannot be accessed internally:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>route[webscoket] <br>
</span>
<div>{<br>
</div>
<div>xlog("L_INFO","Entered websocket route");<br>
</div>
<div># for each branch we will call the function below<br>
</div>
<div>t_on_branch("per_branch_ops");<br>
</div>
<div><br>
</div>
<div># for each reply we will call the function below<br>
</div>
<div>t_on_reply("handle_nat");<br>
</div>
<div># initial invites from the main registrar - need to look them up!<br>
</div>
<div>if (is_method("INVITE"))<br>
</div>
<div> if($Ri == "1.1.1.1" and $Rp == 5070) <br>
</div>
<div> {<br>
</div>
<div> xlog("L_INFO","Call received for a websocket client");<br>
</div>
<div> if (!mid_registrar_lookup("location")) <br>
</div>
<div> {<br>
</div>
<div> t_reply("404", "Not Found");<br>
</div>
<div> exit;<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<div> } <br>
</div>
<div> else if($Ri=="1.1.1.1" && $Rp == "8080")<br>
</div>
<div> {<br>
</div>
<div> xlog("L_INFO","Inbound call received on port 8080");<br>
</div>
<div> route("ToInternal");<br>
</div>
<div> t_on_failure("int_invites");<br>
</div>
<div> } <br>
</div>
<div><br>
</div>
<div>if((is_method("REGISTER"))&&($Ri=="1.1.1.1")&&($Rp =="8080"))<br>
</div>
<div>{<br>
</div>
<div> xlog("L_INFO","Register received - mid-registrar actions");<br>
</div>
<div> fix_nated_register();<br>
</div>
<div> mid_registrar_save("location");<br>
</div>
<div> switch ($retcode) <br>
</div>
<div> {<br>
</div>
<div> case 1:<br>
</div>
<div> xlog("L_INFO", "forwarding REGISTER to main registrar...\n");<br>
</div>
<div> $ru = "sip:2.2.2.2:5060";<br>
</div>
<div> force_send_socket(UDP:1.1.1.1:5070);<br>
</div>
<div> if (!t_relay()) {<br>
</div>
<div> send_reply("500", "Server Internal Error 1");<br>
</div>
<div> }<br>
</div>
<div> t_on_failure("int_invites");<br>
</div>
<div> break;<br>
</div>
<div> case 2:<br>
</div>
<div> xlog("L_INFO", "REGISTER has been absorbed!\n");<br>
</div>
<div> break;<br>
</div>
<div> default:<br>
</div>
<div> xlog("L_ERR", "mid-registrar error!\n");<br>
</div>
<div> send_reply("500", "Server Internal Error 2");<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<div> exit;<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div># removing the rtpproxy session<br>
</div>
<div>if(is_method("CANCEL|BYE"))<br>
</div>
<div>{<br>
</div>
<div> rtpengine_delete();<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div> # try to send the request on its way, if it fails send back a<br>
</div>
<div> # stateless error to the requestor<br>
</div>
<div> if (t_relay())<br>
</div>
<div> {<br>
</div>
<div> xlog("L_INFO", "$ci|pass|$rd:$rp");<br>
</div>
<div> }<br>
</div>
<div> else<br>
</div>
<div> {<br>
</div>
<div> xlog("L_ERR", "$ci|end|unable to relay message");<br>
</div>
<div><br>
</div>
<div> sl_reply_error();<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<div><br>
</div>
<span>}</span><br>
</div>
</body>
</html>