Search code examples
sipkamailio

SIP reply status code and reason null in failure_route


I'm trying to debug why I get null null when logging the value of $rs $rr using the following kamailio configuration.

Inside request_route:

if (is_method("REGISTER")) {
    t_on_reply("REGISTER_FROM_USER");
    # In case of a failure, do a failover:
    t_on_failure("FAILURE_TO_REGISTRAR");
}

Inside the failure_route:

failure_route[FAILURE_TO_REGISTRAR] {
  xlog("L_INFO","Registrar replied (failure): $rs $rr\n");

This outputs:

Registrar replied (failure): <null> <null>

Solution

  • In failure_route the SIP request (e.g., REGISTER, INVITE) of the transaction is under processing, not the SIP response that triggered the execution of the failure_route. This is identified in the core documentation on failure_route here as so:

    Note that in 'failure_route' is processed the request that initiated the transaction, not the reply .

    If the message under processing is a response, $rs and $rr return the response code and reason text. In this case, the message under processing is the request, so these variables both return null.

    To get the response code and reason text in a failure_route, use the transaction variables T(reply_code) and T(reply_reason) as described here