BelledonneCommunications / linphone-sdk

Mirror for linphone-sdk (https://gitlab.linphone.org/BC/public/linphone-sdk.git)
GNU Affero General Public License v3.0
99 stars 79 forks source link

[Bug]: Contact header is not set by natPolicy or manually for register #397

Open nigeldaniels opened 2 months ago

nigeldaniels commented 2 months ago

Context

I use the linphone-sdk ( kotlin) for android. When attempting to register the Contact header field is automatically generated and not the correct one that should be discovered by my natPolicy

    private fun register(username: String, password: String, domain: String) {
        val mynatpolicy = core.createNatPolicy()
        mynatpolicy.isStunEnabled = true
        mynatpolicy.stunServer = "stun.gmx.net:3478"
        core.natPolicy = mynatpolicy

        val identity = Factory.instance().createAddress("sip:$username@$domain") 
        val accountParams = core.createAccountParams()
        accountParams.identityAddress = identity

        accountParams.natPolicy = mynatpolicy

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

        val proxyAddress = Factory.instance().createAddress("sip:$domain")
        proxyAddress?.transport = TransportType.Udp
        accountParams.serverAddress = proxyAddress
        accountParams.isRegisterEnabled = true
        accountParams.natPolicy = mynatpolicy
        val account = core.createAccount(accountParams)

        core.addAuthInfo(authInfo)
        account.contactAddress = Factory.instance().createAddress("sip:test@76.132.54.227")
        core.addAccount(account)
        core.defaultAccount = account
    }

In the above code you can see I try to use both nat policy as well as manually setting contact address neither seems to work I am trying to understand what I am doing incorrectly

logs of the register msg that is generated is provided bellow

024-04-28 17:57:43.920 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Linphone core [0xb400007b0b583400] notified [registration_state_changed]
2024-04-28 17:57:43.920 15201-15201 LinphoneDebug           com.trap.trapfone                    I  resolver_process_data dns_res_check() in progress
2024-04-28 17:57:43.921 15201-15201 LinphoneDebug           com.trap.trapfone                    I  stun.gmx.net resolved to 212.227.67.33
2024-04-28 17:57:43.921 15201-15201 LinphoneDebug           com.trap.trapfone                    I  stun.gmx.net resolved to 212.227.67.34
2024-04-28 17:57:43.921 15201-15201 LinphoneDebug           com.trap.trapfone                    I  resolver[0xb4000079db56be30]: starting aaaa timeout since A response is received.
2024-04-28 17:57:43.921 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Stun server resolution successful.
2024-04-28 17:57:43.921 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Ending background task [17190] with name: [Core startup until registration]
2024-04-28 17:57:43.922 15201-15201 LinphoneDebug           com.trap.trapfone                    I  bellesip_wake_lock_release(): Android wake lock released [ref=0x4326]
2024-04-28 17:57:43.933 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Stun server resolution successful.
2024-04-28 17:57:44.023 15201-15201 LinphoneDebug           com.trap.trapfone                    I  sip.opensettlenet.net resolved to 34.168.241.151
2024-04-28 17:57:44.024 15201-15201 LinphoneDebug           com.trap.trapfone                    I  resolver[0xb4000079db5752b0]: starting SRV timer since A/AAAA fallback response is received.
2024-04-28 17:57:44.024 15201-15201 LinphoneDebug           com.trap.trapfone                    I  channel[0xb400007bf7ec2e00]: entering state RES_DONE
2024-04-28 17:57:44.024 15201-15201 LinphoneDebug           com.trap.trapfone                    I  transaction [0xb400007a0b5c8190] channel state changed to [RES_DONE]
2024-04-28 17:57:44.024 15201-15201 LinphoneDebug           com.trap.trapfone                    I  channel[0xb400007bf7ec2e00]: entering state CONNECTING
2024-04-28 17:57:44.026 15201-15201 LinphoneDebug           com.trap.trapfone                    I  transaction [0xb400007a0b5c8190] channel state changed to [CONNECTING]
2024-04-28 17:57:44.026 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Trying to connect to [UDP://::ffff:34.168.241.151:5060]
2024-04-28 17:57:44.026 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Channel has local address 10.0.2.16:39295
2024-04-28 17:57:44.026 15201-15201 LinphoneDebug           com.trap.trapfone                    I  channel[0xb400007bf7ec2e00]: entering state READY
2024-04-28 17:57:44.027 15201-15201 LinphoneDebug           com.trap.trapfone                    I  transaction [0xb400007a0b5c8190] channel state changed to [READY]
2024-04-28 17:57:44.027 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Changing [client] [REGISTER] transaction [0xb400007a0b5c8190], from state [INIT] to [TRYING]
2024-04-28 17:57:44.027 15201-15201 LinphoneDebug           com.trap.trapfone                    I  channel [0xb400007bf7ec2e00]: message sent to [UDP://sip.opensettlenet.net:5060], size: [544] bytes
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  REGISTER sip:sip.opensettlenet.net SIP/2.0
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Via: SIP/2.0/UDP 10.0.2.16:39295;branch=z9hG4bK.CNr2HDEs6;rport
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  From: <sip:test@sip.opensettlenet.net>;tag=0En1EBH-S
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  To: sip:test@sip.opensettlenet.net
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  CSeq: 20 REGISTER
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Call-ID: wprGwD9CO~
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Max-Forwards: 70
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Supported: replaces, outbound, gruu, path
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Accept: application/sdp
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Accept: text/plain
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Accept: application/vnd.gsma.rcs-ft-http+xml
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Contact: <sip:test@10.0.2.16:39295;transport=udp>;+sip.instance="<urn:uuid:e6e4e521-31e2-005d-a2ca-06efaf69e670>"
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  Expires: 3600
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  User-Agent: Unknown
2024-04-28 17:57:44.028 15201-15201 LinphoneDebug           com.trap.trapfone                    I  

General information

Expected behaviour

I would have expected that the contact header either be discovered by stun or use the value I set on the account object.

To Reproduce

The code I used is provided above

Additional context

Add any other context about the problem here.

SDK logs URL

Logs are pasted Above.