Hi Daniel,
Sorry for the delayed response—I was away from my laptop. Hope you are doing well.
Thanks for your help! Your code snippet worked perfectly.
While we're on this topic, I wanted to share something I noticed during testing. I used two Kamailio instances—one as a UAC and the other as a UAS. The body content you're seeing comes from the UAC, and here’s the snippet I used:
$uac_req(body) =
"Calling-party:
sip:+6597346599@telco1.com;user=phone\r\n"
+ "Called-party:
sip:+46701234567@telco2.com;user=phone\r\n";
However, I realized that when I tried to retrieve the body on the UAS side using var(body) = $rb, it only captured the first line (Calling-party) and not the second (Called-party).
Do you know why this might be happening? And how can I ensure the UAS receives the full body content sent by the UAC?
Best regards,
Timothy
From: Daniel-Constantin Mierla <miconda@gmail.com>
Sent: Monday, May 26, 2025 6:33 PM
To: Timothy Delin <timothy.delin@singtel.com>; Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] Kamailio Regex
[CAUTION: External email] Do not click links or open attachments unless you recognize the sender and know the content is safe. |
___
Hello,
try:
$(var(body){line.sw,Calling-party}{s.after,:}{s.trim}{uri.user})
Cheers,
Daniel
On 26.05.25 12:13, Timothy Delin wrote:
Hey Daniel,
This is the expected body to be sent by the User Agent Client
Calling-party: sip:+46761153802@telco1.com;user=phone
Called-party: sip:+46701234567@telco2.com;user=phone
The goal is to extract the phone number and store it as a variable which will be used to query to Redis
Best regards,
Timothy
From: Daniel-Constantin Mierla <miconda@gmail.com>
Sent: Monday, 26 May 2025 5:32 pm
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Cc: Timothy Delin <timothy.delin@singtel.com>
Subject: Re: [SR-Users] Kamailio Regex
[CAUTION: External email] Do not click links or open attachments unless you recognize the sender and know the content is safe.
___
Hello,
On 26.05.25 10:46, Timothy Delin via sr-users wrote:
Hi everyone,
I need your advice. I am extracting a SIP Body message from a User Agent Client using the regex as such
“$var(calling_party)= $(var(body){re.subst,/.*Calling-party:\s*sip:(\+[0-9]+)@.*/\1/});”
And I tried to log it as
“xlog("L_INFO", "Extracted number 1: $var(calling_party) <><><>\n");”
However, the output in my logs is only showing as below, where I cannot see any value after my variables.
“1(6) INFO: {1 10 SUBSCRIBE 5017ae21204c72a3} <script>: Extracted number 1: +6512345678”
I suspect this is the reason why when I tried to use this variable in a redis_cmd, it returns as null as the variable may have impacted the command input to Redis.
I tried to change the $var(calling_party)=”+6512345678” and it is working perfectly fine
maybe you can give and example of such body so we can try to suggest solutions. Looking at the regex and not knowing the input is not easy to guess.
Cheers,
Daniel--Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/micondaKamailio Consultancy, Training and Development Services -- asipto.comKamailio Scalability Training - Online, June 16-19, 2025 -- asipto.com
--
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy, Training and Development Services -- asipto.com
Kamailio Scalability Training - Online, June 16-19, 2025 -- asipto.com