Apart from my client, I have liblinphone android client in my android device.
I am developing a soft client and it should connect to my asterisk SIP server.
Now I have number1(say 14109092000) connected to asterisk server using my own soft client. I use liblibphone client with number2(say (14109092001) to connect to same asterisk server.
When liblinphone client is turned off or uninstalled, my client is able to connect to my asterisk server.
My own soft client uses port 5060 and liblinphone also uses the same.
Here is the code snippet of my android activity that registers to sip server.
Register.java
String mobNumber = "14109092000";
String domain = <some ip address;
StringBuffer sipAddress = new StringBuffer("sip:").append(mobNumber).append("@").append(domain);
String identity = sipAddress.toString();
LinphoneCore lc = null;
try {
lc = LinphoneCoreFactory.instance().createLinphoneCore(new SndNumberCoreListenerImpl(), getApplicationContext());
LinphoneProxyConfig proxy_cfg;
/*parse identity*/
LinphoneAddress from = LinphoneCoreFactory.instance().createLinphoneAddress(sipAddress.toString() );
from.setPort(5060);
LinphoneAuthInfo info = LinphoneCoreFactory.instance().createAuthInfo(mobNumber, mobNumber,null, domain); /*create authentication structure from identity*/
lc.addAuthInfo(info); /*add authentication info to LinphoneCore*/
/*create proxy config*/
proxy_cfg = lc.createProxyConfig(sipAddress.toString(),domain,null,true);//lc.createProxyConfig();
// configure proxy entries
proxy_cfg.setIdentity(identity); /*set identity with user name and domain*/
String server_addr = from.getDomain(); /*extract domain address from identity*/
proxy_cfg.setProxy(server_addr); /* we assume domain = proxy server address*/
proxy_cfg.enableRegister(true); /*activate registration for this proxy config*/
lc.addProxyConfig(proxy_cfg); /*add proxy config to linphone core*/
lc.setDefaultProxyConfig(proxy_cfg);/*set to default proxy*/
lc.addListener(new SndNumberCoreListenerImpl());
proxy_cfg.done();
while(switchState) {
lc.iterate();
sleep(50);
}
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
1) Why is this happening? 2) How can I prevent this?
Maybe outgoing port of both clients are the same, try to use option "useRandomPort" or set outgoing socket port manually. In LinphonePreferences class there is an option useRandomPort, you can check it out in Linphone app, in network settings.