簡體   English   中英

Linphone SDK 在連接到本地網絡時在 Android 設備中給出 io 錯誤

[英]Linphone SDK gives io error in Android Devices when connecting to local network

我已經成功地將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 Android App中測試了我們本地網絡的憑據,它工作正常。 但是當嘗試登錄我的應用程序時它會引發錯誤。

我已添加此代碼以在 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")
            }
        }
    }

我認為您的問題是您嘗試手動設置 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)

並附上它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM