[OpenSIPS-Users] Help with Adding Custom SIP Header to Relayed CANCEL Request in OpenSIPS

Mohamed OUALLA oualla.simohamed at gmail.com
Thu Aug 15 16:50:04 UTC 2024


Hi Bogdan-Andrei,

  This indeed has solved my problem!

Here is my new code:
```


# CANCEL processing
if ( is_method("CANCEL") ) {
if ( t_check_trans() ){
t_add_cancel_reason("X-Reason: Q.850;cause=31\r\n");
t_relay();
}
exit;
}
 ```
  Thank you very much.

Best regards,

On Wed, Aug 14, 2024 at 3:58 PM Bogdan-Andrei Iancu <bogdan at opensips.org>
wrote:

> Hi,
>
> Take a look at this
> https://blog.opensips.org/2016/11/15/cancel-request-and-reason-header/
>
> Regards,
>
> Bogdan-Andrei Iancu
>
> OpenSIPS Founder and Developer
>   https://www.opensips-solutions.com
>   https://www.siphub.com
>
> On 14.08.2024 06:46, Mohamed OUALLA wrote:
>
> Hello everyone,
>
>   I am currently working with OpenSIPs in stateful mode, and I am
> encountering an issue with relaying a CANCEL request to cancel a pending
> initial SIP INVITE.
>
>   The CANCEL request is hop-by-hop, so OpenSIPs act on it first "*send
> 200 canceling*" then it generates a CANCEL SIP Request and relay it to
> the next hop. My goal is to add a custom SIP header, specifically "
> *X-Reason*", to this relayed CANCEL request. Unfortunately, I am only
> able to add the standard "*Reason*" header.
>
>   The challenge I am facing is that FreeSWITCH, which receives the relayed
> CANCEL request, removes the "Reason" header due to a parameter I have set
> to disable adding Q.850 reasons. This parameter was initially enabled to
> prevent FreeSWITCH from adding the "Reason" header to negative SIP
> responses, but it's now also affecting the CANCEL request, leading to the
> removal of the "Reason" header!
>
> Here’s my current OpenSIPs configuration that successfully adds the
> "Reason" header to the CANCEL request:
>
> ```
>
> if(!is_present_hf("Reason")){
>     append_hf("Reason: Q.850;cause=32\r\n", "CSeq"); #the outgoing CANCEL
> request has the Reason header value now
> }
> ```
>
>   However, when I try to add headers like "*X-Reason*" or "*TestHeader*"
> for example, they don't seem to be included in the relayed CANCEL request:
>
> ```
>
> if(!is_present_hf("Reason")){
>     append_hf("X-Reason: Q.850;cause=31\r\n", "CSeq"); # No changes are
> reflected in the relayed CANCEL request :-/
>     # or
>     append_hf("TestHeader: Q.850;cause=31\r\n", "CSeq");# No changes are
> reflected in the relayed CANCEL request :-/
> }
> ```
>
>   Has anyone faced a similar issue or have any suggestions on how I can
> successfully add a custom "*X-Reason*" header or any other custom "
> *X-Header*" to the relayed CANCEL request?
>
> Thanks in advance,
>
> Have a beautiful day
>
> _______________________________________________
> Users mailing listUsers at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>

-- 
==============================
Mohamed OUALLA
*VoIP Technical Solutions and Software Engineer*
Mail: oualla.simohamed at gmail.com
N.Phone: +212 6 29 19 3116
<oualla.simohamed at gmail.com>*SSC Certified Professional*
==============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20240815/1e9d08ef/attachment.html>


More information about the Users mailing list