Hi,
I have a scenario where I want to send a custom SIP package whenever a call is successfully established or definitely missed. This works pretty well, except when a user has multiple devices online.
I need to send exactly one packet. When initiating the call I set a flag, in the reply route I check for that flag, and on the first 4xx or 2xx response the packet gets sent out. After that I reset the flag, so no other packet is generated for another response coming in.
Now when a user has two devices and rejects the call on the first one but accepts it on the second, I see this call as missed, not answered. So I need to use the first 2xx response or the last 4xx response. For that I need to find out how many branches are open at the moment. But I'm missing something. I registered two devices on the same AOR. I tried accessing $branch(count) in the onreply route, but it is always 0. $br and $bR are <null>.
Does anyone have an idea, how to get that information in the reply_route?
Best Regards, Sebastian
Hello,
On 04/06/14 11:49, Sebastian Damm wrote:
Hi,
I have a scenario where I want to send a custom SIP package whenever a call is successfully established or definitely missed. This works pretty well, except when a user has multiple devices online.
I need to send exactly one packet. When initiating the call I set a flag, in the reply route I check for that flag, and on the first 4xx or 2xx response the packet gets sent out. After that I reset the flag, so no other packet is generated for another response coming in.
Now when a user has two devices and rejects the call on the first one but accepts it on the second, I see this call as missed, not answered. So I need to use the first 2xx response or the last 4xx response. For that I need to find out how many branches are open at the moment. But I'm missing something. I registered two devices on the same AOR. I tried accessing $branch(count) in the onreply route, but it is always 0. $br and $bR are <null>.
Does anyone have an idea, how to get that information in the reply_route?
try to save the number of branches in an avp before t_relay() in request_route.
Cheers, DAniel
Hi Daniel,
On Fri, Jun 6, 2014 at 10:21 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
try to save the number of branches in an avp before t_relay() in request_route.
I just tried that, but it looks strange.
This is how my route for t_relay looks like:
route[2] {
xlog("L_DBG", "Sending out packet $rm stateful.\n"); if (is_method("INVITE")) { xlog("L_INFO", "REQUEST: Open branches: $avp(s:branches) T=$tU\n"); if (defined ($avp(s:branches))) { xlog("L_INFO", "REQUEST: branches avp is defined\n"); $avp(s:branches) = $avp(s:branches) + 1; xlog("L_INFO", "REQUEST: branches avp is now: $avp(s:branches) T=$tU\n"); } else { xlog("L_INFO", "REQUEST: branches avp is NOT defined\n"); $avp(s:branches) = 1; xlog("L_INFO", "REQUEST: branches avp is now: $avp(s:branches) T=$tU\n"); } } if (!t_relay()) {
xlog("L_ERR", "route(2): error to <$tu> from <$fu>\n");
sl_reply_error(); return; }; return; }
Additionally I have a route called from a named reply_route, where I print the number of branches:
xlog("L_INFO", "REPLY: Number of open branches: $avp(s:branches) T=$tU\n");
Now, when I run this code, calling the extension 1016908e0 with two devices registered to it, the log gives me the following output:
Jun 12 08:39:26 hagi /usr/sbin/kamailio[32497]: INFO: <script>: REQUEST: Open branches: <null> T=1016908e0 Jun 12 08:39:26 hagi /usr/sbin/kamailio[32497]: INFO: <script>: REQUEST: branches avp is NOT defined Jun 12 08:39:26 hagi /usr/sbin/kamailio[32497]: INFO: <script>: REQUEST: branches avp is now: 1 T=1016908e0 [..] Jun 12 08:39:31 hagi /usr/sbin/kamailio[32499]: NOTICE: <script>: reply: 486 Busy Here - M=INVITE F=sip:021163555552@sipgate.de T= sip:1016908e0@sipgate.de SRCIP=217.10.66.131:5070 Jun 12 08:39:31 hagi /usr/sbin/kamailio[32499]: INFO: <script>: REPLY: Number of open branches: 18446744073709551613 T=1016908e0
Both phones do ring. I would expect to see the REQUEST part twice, once for each branch, but it is only executed once. And the AVP doesn't survive, carries a completely wrong value.
Do you have any idea, why Kamailio is doing this?
Best Regards, Sebastian
It may work catching 200 OK in reply_route, but catching >=300 in failure route. The failure route is executed only once for all branches (it chooses the most important response code)
regards Klaus
Am 04.06.2014 11:49, schrieb Sebastian Damm:
Hi,
I have a scenario where I want to send a custom SIP package whenever a call is successfully established or definitely missed. This works pretty well, except when a user has multiple devices online.
I need to send exactly one packet. When initiating the call I set a flag, in the reply route I check for that flag, and on the first 4xx or 2xx response the packet gets sent out. After that I reset the flag, so no other packet is generated for another response coming in.
Now when a user has two devices and rejects the call on the first one but accepts it on the second, I see this call as missed, not answered. So I need to use the first 2xx response or the last 4xx response. For that I need to find out how many branches are open at the moment. But I'm missing something. I registered two devices on the same AOR. I tried accessing $branch(count) in the onreply route, but it is always 0. $br and $bR are <null>.
Does anyone have an idea, how to get that information in the reply_route?
Best Regards, Sebastian
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hi,
On Wed, Jun 11, 2014 at 5:59 PM, Klaus Darilion < klaus.mailinglists@pernau.at> wrote:
It may work catching 200 OK in reply_route, but catching >=300 in failure route. The failure route is executed only once for all branches (it chooses the most important response code)
I just tried that, but it looks like I can't access the $rs variable in failure route.
I have a failure route which looks like this:
failure_route["acc"] { xlog("L_INFO", "FAILURE: Found status $rs, handling.\n"); route("accounting"); }
The log gives me this output: Jun 12 10:27:02 hagi /usr/sbin/kamailio[2988]: INFO: <script>: FAILURE: Found status <null>, handling.
I know that I can check for the code with t_check_status(), but how do I just read the final status of the transaction?
Best Regards, Sebastian
Hello,
$rs is set when handling a sip response, in failure_route use $T(reply_code):
http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#t_name
Cheers, Daniel
On 12/06/14 10:45, Sebastian Damm wrote:
Hi,
On Wed, Jun 11, 2014 at 5:59 PM, Klaus Darilion <klaus.mailinglists@pernau.at mailto:klaus.mailinglists@pernau.at> wrote:
It may work catching 200 OK in reply_route, but catching >=300 in failure route. The failure route is executed only once for all branches (it chooses the most important response code)
I just tried that, but it looks like I can't access the $rs variable in failure route.
I have a failure route which looks like this:
failure_route["acc"] { xlog("L_INFO", "FAILURE: Found status $rs, handling.\n"); route("accounting"); }
The log gives me this output: Jun 12 10:27:02 hagi /usr/sbin/kamailio[2988]: INFO: <script>: FAILURE: Found status <null>, handling.
I know that I can check for the code with t_check_status(), but how do I just read the final status of the transaction?
Best Regards, Sebastian
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users