-1

I have successfully integrated Linphone SDK in my project with their dependency.

    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'

And It is working completely ok when using credentials of linphone.But When I am trying to use our sip credentials of PBX It throws io error

I have tested our credentials of our local network in Linphone Android App It works fine. But when try to login in my app It throws error.

I have added this code for login in 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")
            }
        }
    }

1 Answers1

0

I think your issue is that you try to manually set the DNS servers. Try removing this part of your code:

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 already handles that part.

Otherwise it looks OK. If issue persists enable debug logs

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)

and attach them.

Viish
  • 434
  • 4
  • 12