Summary:ASTERISK-17306: SIP Realtime: Peer isn't deleted/cleared from 'sip show peers' when the phone unregister
Reporter:ibercom (ibercom)Labels:
Date Opened:2011-01-28 14:17:24.000-0600Date Closed:2015-01-09 18:49:58.000-0600
Versions:Frequency of
Description:I use cache realtime friends. When the registration expires (rtautoclear=yes), the friend vanish from the configuration until requested again. It is ok. But when the phone unregisters (x-lite) the friend continues existing. 'sip show peer' shows the peer in UNKNOWN status forever.
In a multiserver environment it is a problem because the phone can be registered in other server and the database have correct information, but the first server can't call this phone because it is in memory and it don't load information from the database. You need use sip prune realtime xxxx and then it is ok.


Asterisk 1.4.38

Realtime SIP Settings:
 Realtime Peers:         Yes
 Realtime Users:         Yes
 Cache Friends:          Yes
 Update:                 Yes
 Ignore Reg. Expire:     Yes
 Save sys. name:         Yes
 Auto Clear:             120 (Enabled)

Comments:By: Leif Madsen (lmadsen) 2011-01-31 15:22:28.000-0600

After a discussion with Tilghman on IRC it appears there may be a bug here that needs to be resolved. Acknowledging issue.

By: ibercom (ibercom) 2011-02-10 12:39:45.000-0600

I don't know C language. But afterwards seek inside the code of the chan_sip.c, if I comment the part of the code where the phone unregister it works better. The peer expire ok and it's not in unknown state and the cached peer is cleared.
Although more slowly, max. 3600 sec. since it is not immediate. But this isn't the solutions, I know.

Asterisk 1.4.38 - chan_sip.c - Commented lines:

8847 /* This means remove all registrations and return OK */
8848 memset(&peer->addr, 0, sizeof(peer->addr));
8849 if (!AST_SCHED_DEL(sched, peer->expire)) {
8850 struct sip_peer *peer_ptr = peer;
8851 ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
8852 }
8854 destroy_association(peer);
8856 register_peer_exten(peer, 0); /* Add extension from regexten= setting in sip.conf */
8857 peer->fullcontact[0] = '\0';
8858 peer->useragent[0] = '\0';
8859 peer->sipoptions = 0;
8860 peer->lastms = 0;
8861 peer->portinuri = 0;
8862 pvt->expiry = 0;

By: ibercom (ibercom) 2011-03-07 16:20:04.000-0600

What about this ? Any update on this issue.

By: ibercom (ibercom) 2011-04-25 13:52:06

I have tried the patch (https://issues.asterisk.org/file_download.php?file_id=25884&type=bug) of the bug 16033. It works but it generates an error: chan_sip.c: Unreferencing unreferenced (object)! and asterisk crash.

By: ibercom (ibercom) 2011-04-27 16:08:41

You can close this bug, the patch of 16033 resolves this problem.