1

除了我的客户端,我的 android 设备中还有 liblinphone android 客户端。

我正在开发一个软客户端,它应该连接到我的星号 SIP 服务器。

现在我有 number1(比如 14109092000)使用我自己的软客户端连接到星号服务器。我使用带有 number2 的 liblibphone 客户端(比如(14109092001)连接到同一个星号服务器。

当 liblinphone 客户端关闭或卸载时,我的客户端能够连接到我的星号服务器。

我自己的软客户端使用端口 5060,liblinphone 也使用相同的端口。

这是我注册到 sip 服务器的 android 活动的代码片段。

注册.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)为什么会这样?2)我怎样才能防止这种情况?

4

1 回答 1

0

可能两个客户端的传出端口相同,尝试使用选项“useRandomPort”或手动设置传出套接字端口。在LinphonePreferences类中有一个选项 useRandomPort,您可以在 Linphone 应用程序的网络设置中查看它。

if(isRandomPort){
    LinphonePreferences.instance().useRandomPort(true);
}else {
    LinphonePreferences.instance().useRandomPort(false);
    LinphonePreferences.instance().setSipPort(5060);
}
于 2017-05-12T06:46:21.277 回答