Summary:ASTERISK-22075: Mutliple SIP NOTIFIES at "sip reload" if mailbox is monitored by multiple sip peers
Reporter:mdu113 (mdu113)Labels:
Date Opened:2013-07-15 11:49:52Date Closed:2017-07-25 17:15:21
Status:Closed/CompleteComponents:Applications/app_voicemail Channels/chan_sip/General
Versions: Frequency of
Environment:Attachments:( 0) debug.log
Description:If VM box is monitored by multiple sip peers then asterisk will send multiple SIP notifies about this mailbox to each peer at "sip reload". If number of peers monitoring the mailbox is N then the number of notifies asterisk sends to each peer is N+1. Total number of notifies = N*(N+1).
This will happen only if "pollmailboxes=yes" is present in voicemail.conf.

The relevant parts of configs are follows:





With this config 12 notifies about 650@xyz is sent. This results in storm of notifies if any significant number of peers are monitoring a mailbox and is just obviously wrong.
Comments:By: mdu113 (mdu113) 2013-07-15 11:52:14.692-0500

asterisk debug.log of "sip reload"

By: mdu113 (mdu113) 2013-07-15 12:25:37.395-0500

I've tried to analyze the code and here's what I've found.
When pollmailboxes is set to "yes", app_voicemail registers callback mwi_sub_event_cb() that is called whenever something subscribes to MWI. In that callback mailbox is polled and MWI notification is queued (app_voicemail.c: handle_subscribe() -> poll_subscribed_mailbox()). When notification is queued it then being sent to all peers subscribed for that mailbox MWI (chan_sip.c: mwi_event_cb() -> sip_send_mwi_to_peer()).
Now at "sip reload" in build_peer() function there's a call to add_peer_mwi_subs() which resubscribes the peer to MWI event for the peer's mailboxes, which results in SIP NOTIFYs being sent to all subscribed peers due to above described logic in app_voicemail.c. Since build_peer() is called for every peer, the process is repeated for every peer which results in multiple NOTIFYs.
To illustrate it, suppose 3 peers (p1,p2 and p3 are monitoring mailbox X). At "sip reload" time when build_peer() is called for 'p1' it results in NOTIFYs sent to all p1,p2 and p3. Later when it's called for 'p2' it again results in NOTIFY's sent to all p1,p2 and p3. And so on.
To add insult to injury, in chan_sip.c build_route(), after call to add_peer_mwi_subs(), it also calls sip_send_mwi_to_peer(), which results in additional set of NOTIFYs.

By: Rusty Newton (rnewton) 2017-07-25 17:15:21.174-0500

We are cleaning up the issue tracker. This issue was filed against Asterisk versions that are no longer supported, so we are closing it out as Won't Fix.

If the issue still exists in a recent and supported version of Asterisk then please file a new issue with debug and configuration from the supported version.