linphone python and SIP deregistration

I developed a SIP client in python running on ubuntu 16.04 It registers, it can take calls and record audio etc. All fine. However it doesnt de-register properly (i.e. I don´t get a SIP REGISTER with expires = 0 going out) and this is causing problems in the network (they considered my client to be a abusive user and block it temporarily).

I would like to clean the registration when the logic is over.

This is the code I use to register:

proxy_cfg = self.core.create_proxy_config()
address = self.core.create_address ("sip:" + username + "@" + self.cfg_sip_domain)
address.port = self.cfg_sip_port
proxy_cfg.identity_address = address
proxy_cfg.server_addr = self.cfg_sip_proxy
proxy_cfg.register_enabled = True
self.core.add_proxy_config(proxy_cfg)
self.core.default_proxy_config = proxy_cfg
auth_info = self.core.create_auth_info(username, None, password, None, None, self.cfg_sip_domain)
self.core.add_auth_info(auth_info)

And this is the code I use to de-register. I have tried 2 combinations, setting the register_enabled to False and to True, always with the expires = 0. But no SIP message comes out:

self.core.default_proxy_config.edit()
self.core.default_proxy_config.register_enabled = True
self.core.default_proxy_config.expires = 0
self.core.default_proxy_config.done()

Thanks for the help, Ester

Upvotes: 2

Views: 335

Answers (1)

I tried the following and it works. I do not think it´s very intuitive in the API. According to the docs refresh_register () method triggers to a new REGISTER in the next iteration and it will register with expires = 0.....

        self.core.default_proxy_config.edit()
        self.core.default_proxy_config.expires = 0
        self.core.default_proxy_config.refresh_register()
        self.core.default_proxy_config.done()

Upvotes: 0

Related Questions