Res_mwi_external and app_voicemail

I’ve been trying to see if res_mwi_external is a good solution for some non-voicemail related MWI needs. I already have voicemail on my Asterisk system and MWI working fine, but I am trying to add Station Message Waiting and thinking of the best way of doing that.

While the Asterisk documentation officially says app_voicemail and res_mwi_external cannot be used together, it seems there was a change 5 years ago which makes that no longer the case:

  • app_voicemail and res_mwi_external can now be built together. The default remains to build app_voicemail and not res_mwi_external but if they are both built, the load order will cause res_mwi_external to load first and app_voicemail will be skipped. Use ‘preload=app_voicemail.so’ in modules.conf to force app_voicemail to be the voicemail provider.

Looking through the code, this seems like a good fit for my needs: asterisk/res_mwi_external.c at master · asterisk/asterisk · GitHub

I recompiled with res_mwi_external and added the preload => app_voicemail.so to my modules.conf as instructed so that voicemail would still work. Now, both are built together fine, but res_external_mwi will not load. If I try to manually load it, I get:

Unable to load module res_mwi_external
Command 'module load res_mwi_external' failed.
[2021-04-18 09:22:36] WARNING[25864]: app.c:457 __ast_vm_register: Voicemail provider already registered by app_voicemail.
[2021-04-18 09:22:36] ERROR[25864]: res_mwi_external.c:941 load_module: Failure registering as a voicemail provider

So, it seems as if they cannot both be used simultaneously, which seems to contradict what the change suggested.

I don’t want to use res_mwi_external for voicemail, only for MWI. Right now, I can manually send an MWI notify with something like “sip notify activate-mwi mysipdevice” and clear using a similar CLI command. This works well for activating, but I only want to clear MWI if all messages are gone. The fact that voicemail also does MWI complicates things. It seemed res_mwi_external would allow for the creation of pseudo mailboxes to make this easier, including for lines without voicemail.

What I’m trying to avoid doing is storing messages in AstDB and then having to repeatedly send an MWI activate/clear notify every time, say, the phone goes back on hook. It seems res_mwi_external could handle the MWI for me - but can it really be used in conjunction with app_voicemail?

It can’t be. Effectively there can’t be two definitive sources of mailbox information, it’s one or the other.

The full commit message[1] also states why the change you referenced was done.

[1] https://gerrit.asterisk.org/c/asterisk/+/1884

Ah, that would explain what I’m seeing then. It doesn’t seem like there are any other MWI-related resources, so I’m guessing I’ll need to do a custom solution?

Is the underlying MWI functionality used by app_voicemail and res_mwi_external exposed in any other way that I could use (similar to how Voicemail sends MWI when there are > 0 messages and removes it when there are < 1)? Even if I wrote my own code for sending SIP NOTIFYs, that wouldn’t, say, work for DAHDI, so a channel agnostic method would be nicer.

The modules implement defined core APIs for retrieving mailbox information, and they also publish events when mailbox information changes. This information is then used by consumers such as PJSIP for MWI notification.

There is no defined or supported mechanism for having two things do this at once. If you do anything, then you’re in uncharted territory.

Okay, I see, thanks.

Taking a look at this: https://wiki.asterisk.org/wiki/display/AST/Message+Waiting+Indication:

The sections " Outbound MWI subscription with chan_sip" and " Reception of unsolicited MWI NOTIFY with chan_sip" appear to be separate from “res_external_mwi” at the bottom.

It seems like maybe using SIP_Remote, I could (at least for SIP), define pseudo-mailboxes with a registration like this: mwi => user[:secret[:authuser]] @host [:port]/mailbox

I would need to put together a program that responded correctly, which might not be trivial, but it seems like such a pseudo voicemail server used for MWI would work. I’m assuming doing it this way would not cause a conflict (two things at once), since the external MWI would be tapping into the existing MWI support for voicemail?

The page says this functionality doesn’t yet exist in PJSIP, but I’m still using SIP for now so that would not be an issue.

I can’t comment on the chan_sip functionality, haven’t touched it or used it or looked at it in years upon years.