Search code examples
pythonsipvoiplinphonelinphone-sdk

linphone (Python) Change Port number


I am using linphone 3.9

I tried to change default ports by changing port in SipTransprts but still 5060 still the default value My Question how to change default port for udp and tcp in Linphone lib python ?

  core = linphone.Core.new(callbacks, None, None)
address = linphone.Address.new("sip:"+username+"@"+domain)
address.username = username
address.port =random.randint(5063,6060) 
print address.port
proxy_cfg = core.create_proxy_config()
proxy_cfg.identity_address = address
proxy_cfg.server_addr = "<sip:"+domain+">"
authInfo = core.create_auth_info(username, None, password, None, None, domain);
core.add_auth_info(authInfo)
proxy_cfg.register_enabled = True
core.add_proxy_config(proxy_cfg)
tp = core.sip_transports
tp.tcp_port=1011
tp.tls_port=1012
tp.udp_port=1013
print '0000000000000000000000000000000000000000'
print core.sip_transports.udp_port
print '0000000000000000000000000000000000000000'
#print 5060

Solution

  • tp = core.sip_transports
    tp.tcp_port=1011
    tp.tls_port=1012
    tp.udp_port=1013
    core.sip_transports = tp
    

    Basically, it is a "pointer issue". So for example in tp = core.sip_transports, you are assigning the default values for core.sip_transport (i.e 5060). Then you make a copy and then reassign the values. You cannot change the sip_transport values directly.

    see the very end of this code: https://github.com/BelledonneCommunications/linphone/blob/master/tools/python/unittests/test_register.py