How to encode the special character "@" in the username parameter in the URI of the FROM and TO header in the PJSIP library when sending a REGISTER message?

I am developing an iOS application using PJSIP. I want to send a registration message via PJSIP. I have @ in the username, for example nandha@gmail.com .

I encoded @ as % 40 and added the account username as nandha% 40gmail.com and the SIP URL as sip: nandha% 40gmail.com@142.23.16.20 : 2020

I passed the username and pulled the url in PJSIP. The account was added successfully, but it cannot send a REGISTER message to the server.

I think he added the coded username and sip url. when sending a register message, it decoded the value as nandha @ gmail.com @ 142.23.16.20: 2020 , and after the @ symbol it takes the value IP-PORT, for example gmail.com @ 142.23.16.20: 2020

Why doesn't PJSIP send a REGISTER message when encoding a username?

+4
source share
2 answers

As I know, PJSIP automatically decodes encoded characters when splitting @sipIP username: port

+1
source

Ok, you can do this in two ways,

First

[[NSString stringWithFormat:@"<sip:%s@%s:%s;transport=%s>", number, server, port, transport] UTF8String];

Second

pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE, "<sip:%s@%s;transport=%s>", uname, server, transport);
0
source

Source: https://habr.com/ru/post/1677904/


All Articles