Re: PJSIP registration Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello PJSip Team,

   I am implementing PJSip in iOS App. I have added sip user from sever using this method sip_add_account(NSDictionary *account, pjsua_acc_id *acc_id)

But server adds to user detail but not Authenticate, getting the error :

07:44:06.880    pjsua_acc.c !....IP address change detected for account 0 (192.168.0.103:5070 --> 103.87.56.179:50721). Updating registration (using method 4)

07:44:06.880    pjsua_acc.c  ....SIP registration error: No suitable credential (PJSIP_ENOCREDENTIAL) [status=171101]


I do not find out related issues. please help me. When server Add all detail But not authenticate user form server 


Like :


Invite Accept 

##

T 174.67.192.233:64402 -> xxx.xxx.xxx.xxx:5070 [AP]

INVITE sip:19492321401@xxxxxxxxxxxxxxx:5070 SIP/2.0.

Via: SIP/2.0/TCP 192.168.50.107:64402;branch=z9hG4bK254205087;rport;alias.

From: <sip:19494197634@xxx.xxx.xxx.xxx:5070>;tag=1547958148.

To: <sip:19492321401@xxx.xxx.xxx.xxx:5070>.

Call-ID: 80149780-38444-2@xxxxxxxxxxxxxx.

CSeq: 10 INVITE.

Contact: <sip:19494197634@xxx.xxx.xxx.xxx:64402;transport=tcp>.

Max-Forwards: 70.

User-Agent: Grandstream Wave 1.2.9.

Privacy: none.

P-Preferred-Identity: <sip:19494197634@xxx.xxx.xxx.xxx:5070>.

Supported: replaces, path, timer, eventlist.

Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE.

Content-Type: application/sdp.

Accept: application/sdp, application/dtmf-relay.

Content-Length:   719.



But No Authentication & receive a response from Server side


///Save & get value From Preference 

 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:

                        [NSNumber numberWithInt:300], @"regTimeout",

                        [NSNumber numberWithBool:YES], @"enableNat",

                        [NSNumber numberWithBool:NO], @"enableMJ",

                        [NSNumber numberWithInt: 5070], @"localPort",

                        [NSNumber numberWithInt: 4000], @"rtpPort",

                        [NSNumber numberWithInt: 30], @"kaInterval",

                        [NSNumber numberWithBool:YES], @"enableEC",

                        [NSNumber numberWithBool:NO], @"disableVad",

                        [NSNumber numberWithInt: 1], @"codec",

                        [NSNumber numberWithBool:YES], @"dtmfWithInfo",

                        [NSNumber numberWithBool:YES],@"removeIntlPrefix",

                        [NSNumber numberWithBool:NO], @"enableICE",

                        [NSNumber numberWithInt: 3], @"logLevel",

                        [NSNumber numberWithBool:YES],  @"enableG711u",

                        [NSNumber numberWithBool:YES],  @"enableG711a",

                        [NSNumber numberWithBool:YES],   @"enableG722",

                        [NSNumber numberWithBool:YES],   @"enableG7221",

                        [NSNumber numberWithBool:YES],   @"enableG729",

                        [NSNumber numberWithBool:YES],  @"enableGSM",

                        [NSNumber numberWithBool:YES], @"keepAwake",

                        [NSNumber numberWithBool:YES], kVoipOverEdge,

                        [[NSUserDefaults standardUserDefaults] objectForKey:UserPhoneNo_Key], @"username",

                        [[NSUserDefaults standardUserDefaults] objectForKey:UserPwd_Key], @"password",

                        kServer, @"server",

                        kStrnServer, @"proxyServer",

                        kStrnServer, @"PJSipServer",

                        //kStrnServer,@"stunServer",

                        nil];




// Code In Objective c 

pj_status_t sip_connect(pj_pool_t *pool, pjsua_acc_id *acc_id)

{

    pj_status_t status;

    pjsua_acc_config acc_cfg;

    const char *uname;

    const char *authname;

    const char *contactname;

    const char *passwd;

    const char *server;

    

    SiphonApplication *app = (SiphonApplication *)[SiphonApplication sharedApplication];

    

    // TODO Verify if wifi is connected, if not verify if the user wants edge connection

    

    uname  = [[[NSUserDefaults standardUserDefaults] stringForKey:

               @"username"] UTF8String]; // 1234567890

    authname  = [[[NSUserDefaults standardUserDefaults] stringForKey:

                  @"authname"] UTF8String]; //1234567890

    contactname  = [[[NSUserDefaults standardUserDefaults] stringForKey:

                     @"contact"] UTF8String]; //1234567890

    passwd = [[[NSUserDefaults standardUserDefaults] stringForKey:

               @"password"] UTF8String]; // 123456

    server = [[[NSUserDefaults standardUserDefaults] stringForKey:

               @"server"] UTF8String]; //xx.xx.xxx.xx

    

    

    pjsua_acc_config_default(&acc_cfg);

    

    // ID

    acc_cfg.id.ptr = (char*) pj_pool_alloc(/*app_config.*/pool, PJSIP_MAX_URL_SIZE);

    if (contactname && strlen(contactname))

        acc_cfg.id.slen = pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE,

                                           "\"%s\"<sip:%s@%s>", contactname, uname, server);

    else

        acc_cfg.id.slen = pj_ansi_snprintf(acc_cfg.id.ptr, PJSIP_MAX_URL_SIZE,

                                           "sip:%s@%s", uname, server);

     PJ_LOG(1,(THIS_FILE, "'%s'", acc_cfg.id));

    if ((status = pjsua_verify_sip_url(acc_cfg.id.ptr)) != 0)

    {

        PJ_LOG(1,(THIS_FILE, "Error: invalid SIP URL '%s' in local id argument",

                  acc_cfg.id));

        [app displayParameterError: @"Invalid value for username or server."];

        return status;

    }

    // Registrar

    acc_cfg.reg_uri.ptr = (char*) pj_pool_alloc(/*app_config.*/pool,

                                                PJSIP_MAX_URL_SIZE);

    acc_cfg.reg_uri.slen = pj_ansi_snprintf(acc_cfg.reg_uri.ptr,

                                            PJSIP_MAX_URL_SIZE, "sip:%s", server);

    if ((status = pjsua_verify_sip_url(acc_cfg.reg_uri.ptr)) != 0)

    {

        PJ_LOG(1,(THIS_FILE,  "Error: invalid SIP URL '%s' in registrar argument",

                  acc_cfg.reg_uri));

        [app displayParameterError: @"Invalid value for server parameter."];

        return status;

    }

    

    //acc_cfg.id = pj_str(id);

    //acc_cfg.reg_uri = pj_str(registrar);

    acc_cfg.cred_count = 1;

    acc_cfg.cred_info[0].scheme = pj_str("Digest");

    acc_cfg.cred_info[0].realm = pj_str("*");//pj_str(realm);

    if (authname && strlen(authname))

        acc_cfg.cred_info[0].username = pj_str((char *)authname);

    else

        acc_cfg.cred_info[0].username = pj_str((char *)uname);

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"enableMJ"])

        acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_DIGEST;

    else

        acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;

    acc_cfg.cred_info[0].data = pj_str((char *)passwd);

    

    acc_cfg.publish_enabled = PJ_TRUE;

#if defined(MWI) && MWI==1

    acc_cfg.mwi_enabled = PJ_TRUE;

#endif

    

    acc_cfg.allow_contact_rewrite = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableNat"];

    

    // FIXME: gestion du message 423 dans pjsip

    acc_cfg.reg_timeout = [[NSUserDefaults standardUserDefaults] integerForKey: @"regTimeout"];

    if (acc_cfg.reg_timeout < 1 || acc_cfg.reg_timeout > 3600)

    {

        PJ_LOG(1,(THIS_FILE,

                  "Error: invalid value for timeout (expecting 1-3600)"));

        [app displayParameterError:

         @"Invalid value for timeout (expecting 1-3600)."];

        return PJ_EINVAL;

    }

    acc_cfg.reg_retry_interval = 300;

    acc_cfg.reg_first_retry_interval = 60;

    

    // Keep alive interval

    acc_cfg.ka_interval = [[NSUserDefaults standardUserDefaults] integerForKey:@"kaInterval"];

    

    // proxies server

    NSString *proxies = [[NSUserDefaults standardUserDefaults] stringForKey: @"proxyServer"];

    NSArray *array = [proxies componentsSeparatedByString:@","];

    NSEnumerator *enumerator = [array objectEnumerator];

    NSString *anObject;

    while (anObject = [enumerator nextObject])

    {

        NSMutableString *mutableStr = [anObject mutableCopy];

        CFStringTrimWhitespace((CFMutableStringRef)mutableStr);

        const char *proxy = [mutableStr UTF8String];

        if (proxy && strlen(proxy))

        {

            if (acc_cfg.proxy_cnt==PJ_ARRAY_SIZE(acc_cfg.proxy))

            {

                PJ_LOG(1,(THIS_FILE, "Error: too many proxy servers"));

                break;

            }

            pj_str_t pj_proxy;

            pj_proxy.slen = strlen(proxy) + 20;

            pj_proxy.ptr = (char*) pj_pool_alloc(pool, pj_proxy.slen);

            pj_proxy.slen = pj_ansi_snprintf(pj_proxy.ptr, pj_proxy.slen, "sip:%s", proxy);

            if ((status = pjsua_verify_sip_url(pj_proxy.ptr)) != 0)

            {

                PJ_LOG(1,(THIS_FILE,  "Error: invalid SIP URL '%*.s' in proxy argument (%d)",

                          pj_proxy.slen, pj_proxy.ptr, status));

                [app displayParameterError: @"Invalid value for proxy parameter."];

                continue;

            }

            acc_cfg.proxy[acc_cfg.proxy_cnt++] = pj_proxy;

            acc_cfg.reg_use_proxy=3;

        }

    }

    

#if LOCAL_ACCOUNT

    *acc_id = aid;

#else

    status = pjsua_acc_add(&acc_cfg, PJ_TRUE, acc_id);

    if (status != PJ_SUCCESS)

    {

        pjsua_perror(THIS_FILE, "Error adding new account", status);

        [app displayParameterError: @"Error adding new account."];

    }

#endif

    return status;

}


On Mon, Mar 25, 2019 at 1:02 PM Vivek Shukla <vivek.shukla@xxxxxxxxxxxxx> wrote:
I am developing in Objective C code.


On Mon, Mar 25, 2019 at 12:59 PM Vivek Shukla <vivek.shukla@xxxxxxxxxxxxx> wrote:

I am not able to register using registration User: - getting error response please find it.  


223.233.103.239:51627). Updating registration (using method 4)

09:25:01.035    pjsua_acc.c  ....SIP registration error: No suitable credential (PJSIP_ENOCREDENTIAL) [status=171101]

--
Best Regards 

Vivek Shukla 
Sr. iOS Developer 



--
Best Regards 

Vivek Shukla 
Sr. iOS Developer 



--
Best Regards 

Vivek Shukla 
Sr. iOS Developer 

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux