首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linphone SDK在Android设备连接本地网络时出现io错误

Linphone SDK在Android设备连接本地网络时出现io错误
EN

Stack Overflow用户
提问于 2022-09-23 09:11:34
回答 1查看 115关注 0票数 -1

我已经成功地将Linphone 与它们的依赖关系集成到了我的项目中。

代码语言:javascript
复制
    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.But的凭据时,它完全正常,当我尝试使用PBX的sip凭据时,它抛出io错误

我在Linphone安卓应用程序中测试了我们本地网络的认证,它运行得很好。但是当尝试登录我的应用程序时,它会抛出错误。

我添加了这个代码,以便在SIP中登录。

代码语言:javascript
复制
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")
            }
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2022-09-23 12:02:06

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

代码语言:javascript
复制
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已经处理了这个部分。

否则看上去没问题。如果问题持续存在,则启用调试日志

代码语言:javascript
复制
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)

并把它们连接起来。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73825489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档