【问题标题】:Linphone SDK gives io error in Android Devices when connecting to local network连接到本地网络时,Linphone SDK 在 Android 设备中出现 io 错误
【发布时间】:2022-09-23 20:02:06
【问题描述】:

我已经成功整合Linphone SDK在我的项目中与他们的依赖。

    implementation \'org.linphone:linphone-sdk-android:5.1.59\'
    // Adding this dependency allows the linphone-sdk to automatically handle audio focus
    implementation \'androidx.media:media:1.6.0\'

并且在使用 linphone 的凭据时它完全可以正常工作。但是当我尝试使用我们的 PBX 的 sip 凭据时它会抛出io错误

我已经测试了我们本地网络的凭据Linphone安卓应用它工作正常。但是当尝试登录我的应用程序时它会引发错误。

我已添加此代码以在 SIP 中登录。

fun login(domain: String, username: String, password: String) {
        val mgr: ConnectivityManager =
            getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

        val listAddress: MutableList<String> = ArrayList()
        mgr.getLinkProperties(mgr.activeNetwork)?.let{network->
            network.dnsServers.forEach {
                it.hostAddress?.let { it1 -> listAddress.add(it1) }
            }
        }

        core.setDnsServers(listAddress.map { it }.toTypedArray())

        val authInfo =
            Factory.instance().createAuthInfo(username, null, password, null, null, domain, null)

        val params = core.createAccountParams()
        val senderUri = \"sip:$username@$domain\"

        val identity = Factory.instance().createAddress(senderUri)
        params.identityAddress = identity

        val address = Factory.instance().createAddress(\"sip:$domain\")
        address?.transport = TransportType.Tls
        params.serverAddress = address
        params.isOutboundProxyEnabled = true
        params.isRegisterEnabled = true
        val account = core.createAccount(params)

        getInstance().core.addAuthInfo(authInfo)
        getInstance().core.addAccount(account)
        getInstance().core.defaultAccount = account

        core.start()

        account.addListener { _, state, message ->
            Log.e(TAG, \"login: state $state $message\" )
            if (\"$state\" == \"Failed\") {
                Utils().showShortToast(getInstance(), \"Registration Failed\")
            } else if (\"$state\" == \"Ok\") {
                Utils().showShortToast(getInstance(), \"Registration Success\")
            }
        }
    }

    标签: android sip linphone sip-server linphone-sdk


    【解决方案1】:

    我认为您的问题是您尝试手动设置 DNS 服务器。 尝试删除这部分代码:

    val mgr: ConnectivityManager =
        getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
    
    val listAddress: MutableList<String> = ArrayList()
    mgr.getLinkProperties(mgr.activeNetwork)?.let{network->
        network.dnsServers.forEach {
            it.hostAddress?.let { it1 -> listAddress.add(it1) }
        }
    }
    
    core.setDnsServers(listAddress.map { it }.toTypedArray())

    Linphone-SDK 已经处理了这部分。

    否则看起来没问题。如果问题仍然存在,请启用调试日志

    Factory.instance().setLogCollectionPath(context.filesDir.absolutePath)
    Factory.instance().enableLogCollection(LogCollectionState.Enabled)
    Factory.instance().setLoggerDomain(appName)
    Factory.instance().enableLogcatLogs(true)
    Factory.instance().loggingService.setLogLevel(LogLevel.Message)

    并附上它们。

    【讨论】:

      猜你喜欢
      • 2022-11-09
      • 2020-08-22
      • 2020-07-30
      • 2013-02-06
      • 1970-01-01
      • 2020-03-09
      • 2015-06-15
      • 1970-01-01
      • 2012-04-16
      相关资源
      最近更新 更多