问题
I'm using pjsip in my application. At the time of registration I set the timeout to 60 sec. After every 60 seconds my account will re-register but in my case it is not happening. If anybody knows why, please tell me (I set whatever fields required to call pjsip account add method, if i miss any thing please tell me).
setRegistration(String sipUser, String password,String sipServer) {
int status = pjsuaConstants.PJ_FALSE;
/* Register to SIP server by creating SIP account. */
{
int[] accId = new int[1];
accId[0] = 1;
pjsua_acc_config cfg = new pjsua_acc_config();
pjsua.acc_config_default(cfg);
csipsimple_acc_config css_cfg = new csipsimple_acc_config();
pjsua.csipsimple_acc_config_default(css_cfg);
cfg.setPriority(100);
cfg.setId(pjsua.pj_str_copy("sip:" + sipUser + "@" + sipServer));
cfg.setReg_uri(pjsua.pj_str_copy("sip:" + sipServer
+ ";transport=udp;lr"));
cfg.setReg_timeout(60);
cfg.setCred_count(1);
cfg.setPublish_enabled(0);
cfg.setReg_delay_before_refresh(-1);
cfg.setUse_timer(pjsua_sip_timer_use.PJSUA_SIP_TIMER_OPTIONAL);
pjsip_cred_info cred_info = cfg.getCred_info();
cred_info.setRealm(pjsua.pj_str_copy(sipServer));
cred_info.setScheme(pjsua.pj_str_copy("Digest"));
cred_info.setUsername(pjsua.pj_str_copy(sipUser));
cred_info
.setData_type(pjsip_cred_data_type.PJSIP_CRED_DATA_PLAIN_PASSWD
.swigValue());
cred_info.setData(pjsua.pj_str_copy(password));
cfg.setKa_interval(0);
pjsua.csipsimple_set_acc_user_data(cfg, css_cfg);
Log.i("status", "acc is adding....");
status = pjsua.acc_add(cfg, pjsuaConstants.PJ_FALSE, accId);
Log.i("status", "acc is added");
if (status == pjsuaConstants.PJ_SUCCESS) {
status = pjsua.acc_set_online_status(accId[0], 1);
Log.i("Setting online status to online", "---online--" + status);
} else {
Log.i("Not success", "---un success--" + status);
}
}
return status == pjsuaConstants.PJ_SUCCESS;
}
Logs
05-03 12:17:58.820: I/libpjsip(1003): 12:17:58.826 pjsua_acc.c
registration success, status=200 (OK), will re-register in 60 seconds
05-03 12:17:58.820: D/libpjsip(1003): 12:17:58.827 pjsua_acc.c ....Keep-alive timer started for acc 1, destination:4.53.123.201:5060, interval:40s
回答1:
See this
I don't know the problem you were facing but when I tried to use your code I had a problem and I managed to fix it as described in the related question
回答2:
You need to set the interval
cfg.reg_retry_interval
I am pretty sure that Java API provides this property.
来源:https://stackoverflow.com/questions/16353653/account-re-registration-in-pjsip