<HTML><BODY><div><br>Hello Ben,</div><div> </div><div>Thank you for answer.</div><div> </div><div>This is my RELAY route</div><div> </div><div><div>route[RELAY] {<br> if (!t_relay())<br> {<br> sl_reply_error();<br> }</div><div> exit;<br>}<br> </div><div><div>I did the following experiment. Commented out the line</div><div>#sl_reply_error();</div><div><br>Sent Invite and Cancel. Opensips did not send 500.</div><div> </div><div>In fact, it is «sl_reply_error» that sends 500.</div><div>it looks like:</div><div> </div><div>SIP/2.0 500 No destination available (18/SL)</div><div>It is clear now.</div><div> </div><div>Following your advice I tried to use avp variable.</div><div> </div><div>## CANCEL processing<br> if (is_method("CANCEL"))<br> {<br> ## returns true if the current request is associated to a transaction<br> if (t_check_trans())<br> {</div><div> $avp(ci)=&ci<br> t_relay();<br> }<br> exit;<br> }</div><div> </div><div> </div><div>But when I try to use this variable( $avp(ci)) at the [resume] route of rest_client, it is <null></div><div> </div></div></div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Воскресенье, 5 апреля 2020, 16:55 +03:00 от users-request@lists.opensips.org:<br> <div id=""><div class="js-helper js-readmsg-msg"><style type="text/css"></style><div><div id="style_15860949151793570084_BODY">Send Users mailing list submissions to<br><a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>or, via email, send a message with subject or body 'help' to<br><a href="/compose?To=users%2drequest@lists.opensips.org">users-request@lists.opensips.org</a><br><br>You can reach the person managing the list at<br><a href="/compose?To=users%2downer@lists.opensips.org">users-owner@lists.opensips.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Users digest..."<br><br><br>Today's Topics:<br><br> 1. Re: t_forward_nonack failed (Ben Newlin)<br> 2. Re: using load balancer and lookup together (Michael Vale)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Sun, 5 Apr 2020 13:11:34 +0000<br>From: Ben Newlin <<a href="/compose?To=Ben.Newlin@genesys.com">Ben.Newlin@genesys.com</a>><br>To: Oleg Podguyko <<a href="/compose?To=podguiko@mail.ru">podguiko@mail.ru</a>>, OpenSIPS users mailling list<br><<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>Subject: Re: [OpenSIPS-Users] t_forward_nonack failed<br>Message-ID: <<a href="/compose?To=00BE023F%2dDA3A%2d45EE%2d988F%2dBA4891FB9E04@genesys.com">00BE023F-DA3A-45EE-988F-BA4891FB9E04@genesys.com</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>Oleg,<br><br>At first glance, it seems like t_was_cancelled [1] is exactly what you want. However, it can only be called from onreply_route or failure_route, which makes it unusable for this case. This has caused problems for me as well, as it makes it very hard to detect cancellation when working in asynchronous routes that don’t involve SIP messages. Similarly, t_cancel_branch can only be called from onreply_route, which also causes issues with not being able to manage branches with non-SIP async operations. It may be a good feature request to add the ability to use those functions in async resume routes, but for now they will not work.<br><br>However, t_relay itself does not ever generate a 500 error back to the client as far as I know. It can only send a 477 response automatically. Are you sure you are not generating the 500 in your script when handling the error from t_relay? The documentation for the function [2] notes that a -3 response from t_relay indicates the request may have already been cancelled. In that case, you can just exit if you know the 487 has already been sent, or you can send a 487 reply yourself. To be honest, I’m not sure where the 487 is coming from in your case since I didn’t think OpenSIPS would automatically respond with a 487 for a cancelled transaction; I have always had to do that from the script myself. So in addition to sending the 500 reply yourself, you may have some code in your script which is also sending the 487.<br><br>If none of that works, another option would be to set a flag or an avp in the transaction when processing the CANCEL. Then you can check the flag when you receive the HTTP response and if it is set just don’t call t_relay.<br><br>[1] <a href="https://opensips.org/docs/modules/3.0.x/tm.html#func_t_was_cancelled" target="_blank">https://opensips.org/docs/modules/3.0.x/tm.html#func_t_was_cancelled</a><br>[2] <a href="https://opensips.org/docs/modules/3.0.x/tm.html#func_t_relay" target="_blank">https://opensips.org/docs/modules/3.0.x/tm.html#func_t_relay</a><br><br>Ben Newlin<br><br>From: Users <<a href="/compose?To=users%2dbounces@lists.opensips.org">users-bounces@lists.opensips.org</a>> on behalf of Oleg Podguyko via Users <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>Reply-To: Oleg Podguyko <<a href="/compose?To=podguiko@mail.ru">podguiko@mail.ru</a>>, OpenSIPS users mailling list <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>Date: Sunday, April 5, 2020 at 6:31 AM<br>To: users <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>Subject: [OpenSIPS-Users] t_forward_nonack failed<br><br><br>Opensips works like a proxy. Gets an Invite. In the process of processing it, opensips makes a request via http (rest_client module) and receives a response.<br>Adds the received information to Invite (as X-header) and sends through the dispatcher module to freeswitch.<br>Everything is working fine.<br>However, there is a scenario in which everything goes a little wrong.<br>Opensips receives an Invite, starts processing it, sends a request via http. At this time, Cancel arrives at Invite. The transaction is being destroyed. Opensips sends 200 Cancelling, and then 487. And here comes the response via HTTP, but since the transaction is no longer there, this call ends with an error 500 no route to destination when the t_relay function is executed. In this case, a message appears in the log<br>/ usr / sbin / opensips [5577]: ERROR: tm: w_t_relay: t_forward_nonack failed.<br>How to correctly handle such cases in order to prevent such errors in the logs?<br><br>--<br>Oleg Podguyko<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://lists.opensips.org/pipermail/users/attachments/20200405/8680c7ac/attachment-0001.html" target="_blank">http://lists.opensips.org/pipermail/users/attachments/20200405/8680c7ac/attachment-0001.html</a>><br><br>------------------------------<br><br>Message: 2<br>Date: Sun, 05 Apr 2020 23:54:29 +1000<br>From: Michael Vale <<a href="/compose?To=masked@vale.ski">masked@vale.ski</a>><br>To: David Villasmil <<a href="/compose?To=david.villasmil.work@gmail.com">david.villasmil.work@gmail.com</a>>, OpenSIPS users<br>mailling list <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>Subject: Re: [OpenSIPS-Users] using load balancer and lookup together<br>Message-ID: <<a href="/compose?To=6342fd559df4c9765b17270d07bc04f11ad93b36.camel@vale.ski">6342fd559df4c9765b17270d07bc04f11ad93b36.camel@vale.ski</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>Ok, to explain,<br>Using your logic,<br>To call say '555' will goto Voicemail, if I disable voicemail it will<br>return a 404 instead of going to the load balancer.<br>That's fine, if 555 is an extension, but if it's (for this example) a<br>PSTN number (or a all-else catch all, like I'm trying to achieve) thats<br>not OK because I get a 404 rather than it getting routed to the load<br>balancer.<br>If 555 is an extension/user the call will go through to the registered<br>extension, but if it's not registered in the usrloc table, it goes to<br>404, instead of the load balancer.<br>If I reverse the logic, It will goto the load balancer even if it's a<br>registered extension, or Too Many Hops, depending on how I adjust the<br>logic.<br>I cannot seem to create a catch all for non-usrloc registered extension<br>calls to goto the load balancer otherwise return a 404.<br>I hope I explained it well enough. I will keep trying,<br>Regards,<br>Michael.<br>On Sun, 2020-04-05 at 11:47 +0100, David Villasmil wrote:<br>> Why are you trying to do all at once?<br>><br>> Why not first do the lookup<br>><br>> <a href="https://github.com/davidcsi/kamailio-private-public/blob/a81d7f777a8c5ee2dbb32311f7e6b5a3cf94bf32/kamailio.cfg#L771" target="_blank">https://github.com/davidcsi/kamailio-private-public/blob/a81d7f777a8c5ee2dbb32311f7e6b5a3cf94bf32/kamailio.cfg#L771</a><br>><br>><br>> and then start load balancing?<br>><br>> <a href="https://github.com/davidcsi/kamailio-private-public/blob/a81d7f777a8c5ee2dbb32311f7e6b5a3cf94bf32/kamailio.cfg#L1109" target="_blank">https://github.com/davidcsi/kamailio-private-public/blob/a81d7f777a8c5ee2dbb32311f7e6b5a3cf94bf32/kamailio.cfg#L1109</a><br>><br>> Do you have some special need to fulfill?<br>><br>> David<br>> On Sun, 5 Apr 2020 at 06:34, Michael Vale via Users <<br>> <a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>> wrote:<br>> > hi,<br>> ><br>> ><br>> ><br>> > perhaps this can be solved with a failure route and or a check<br>> > status<br>> ><br>> > but i dont know and it would be nice if i could do it without it.<br>> ><br>> ><br>> ><br>> > no matter how i write the script, either a uac to uac call goes to<br>> > the<br>> ><br>> > load balancer or the load balancer is stuck with a 404 reply from<br>> > the<br>> ><br>> > script or uac to uac works but when one end is not registered it<br>> > goes<br>> ><br>> > to the load balancer instead of getting a 404.<br>> ><br>> ><br>> ><br>> > i've tried failure routes and get the same problem. here is a<br>> > snippet.<br>> ><br>> ><br>> ><br>> > if (!lb_start(1,"pstn")) && (!lookup("location","m",)) {<br>> ><br>> > lb_disable_dst();<br>> ><br>> > #route(relay);<br>> ><br>> > #send_reply(404,"No user or gateway");<br>> ><br>> > if (lb_start(1,"pstn")) {<br>> ><br>> > send_reply(500,"SIPSIPSIPS");<br>> ><br>> > # t_relay();<br>> ><br>> > exit;<br>> ><br>> > }<br>> ><br>> > # exit;<br>> ><br>> > } else if (lookup("location","m")) &&<br>> ><br>> > (!lb_start(1,"pstn")) {<br>> ><br>> > lb_disable_dst();<br>> ><br>> > route(relay);<br>> ><br>> > exit;<br>> ><br>> > } else if (lb_start(1,"pstn")) &&<br>> ><br>> > (lookup("location","m")) {<br>> ><br>> > lb_disable_dst();<br>> ><br>> > route(relay);<br>> ><br>> > exit;<br>> ><br>> > } else if (!lookup("location","m")) &&<br>> ><br>> > (!lb_start(1,"pstn")) {<br>> ><br>> > send_reply(404,"Not Found");<br>> ><br>> > exit;<br>> ><br>> > } else if (lb_start(1,"pstn")) &&<br>> ><br>> > (!lookup("location","m")) {<br>> ><br>> > # #lb_disable_dst();<br>> ><br>> > if (!lookup("location","m")) {<br>> ><br>> > route(relay);<br>> ><br>> > exit;<br>> ><br>> > }<br>> ><br>> > if (lookup("location","m")) {<br>> ><br>> > lb_disable_dst();<br>> ><br>> > route(relay);<br>> ><br>> > exit;<br>> ><br>> > }<br>> ><br>> > }<br>> ><br>> ><br>> ><br>> > thanks in advance,<br>> ><br>> ><br>> ><br>> > michael.<br>> ><br>> ><br>> ><br>> ><br>> ><br>> > _______________________________________________<br>> ><br>> > Users mailing list<br>> ><br>> > <a href="/compose?To=Users@lists.opensips.org">Users@lists.opensips.org</a><br>> ><br>> > <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>> ><br>> --<br>> Regards,<br>><br>> David Villasmilemail: <a href="/compose?To=david.villasmil.work@gmail.com">david.villasmil.work@gmail.com</a><br>> phone: <span class="js-phone-number">+34669448337</span><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://lists.opensips.org/pipermail/users/attachments/20200405/6ef5eec8/attachment.html" target="_blank">http://lists.opensips.org/pipermail/users/attachments/20200405/6ef5eec8/attachment.html</a>><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Users mailing list<br><a href="/compose?To=Users@lists.opensips.org">Users@lists.opensips.org</a><br><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br><br><br>------------------------------<br><br>End of Users Digest, Vol 141, Issue 8<br>*************************************</div></div></div></div></blockquote><div> <div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Олег Подгуйко</div></div></div><div> </div></div></BODY></HTML>