Asterisk Realtime & Hints

Hello,

I have a question concerning Asterisk Realtime and the use of hints to offer the current state of a device to subscribed users.

I configured Asterisk to dynamically load the available users from a MySQL database. This part of the configuration works fine and devices are able to register/unregister as such an user at the Asterisk server. Registered users should also have the possibility to subscribe for notifications on an other user’s state. Therefore for each user an extension, which defines a hint, like the on below, is defined (1500 is the user’s name):

[internal] exten => 1500,hint,SIP/1500

It works fine to send a SUBSCRIBE-message from a registered user to the Asterisk server (using “presence” as event and “application/pidf-xml” as content-type) to subscribe for notifications on an other user’s state. After sending the SUBSCRIBE-request a NOTIFY-response is received from Asterisk and each time the state of the subscribed user changes, an other NOTIFY-message is send from Asterisk. Also when I enter “sip show subscriptions” into the CLI all subscriptions are listed properly.

The problem is, that the default state of an unregistered user is “Idle” instead of “Unavailable” such like I would expect it to be. This can be seen by entering “core show hints” into the Asterisk CLI. for example the prompt of this command after restarting Asterisk is the following one, even if the user “1500” has not been registered yet:

*CLI> core show hints -= Registered Asterisk Dial Plan Hints =- 1500 : SIP/1500 State:Idle Watchers 0

When such a user is registered at Asterisk, its state remains “Idle”, but when it is unregistered afterwards, the state switches to “Unavailable”.

This behaviour seems to be connected to the use of Asterisk Realtime, because when I manually configure a user, which is stored in the database in the sip.conf, the state of the user’s hint is “Unavailable” by default. The following configuration shows the definition of a user in the sip.conf configuration file, which consists of the same properties like the ones defined in the database:

[1500]
callerid=1500
context=internal
canreinvite=no
insecure=port
type=friend
host=dynamic
secret=passwd
allow=all
nat=yes
mailbox=1500

In sip.conf the options “rtcachefriends=yes” and “rtupdate=yes” are set, but I also tried setting them to “no” without any success.

I am wondering, if this behaviour of Asterisk is caused by a configuration issue!? Is it even possible to use hints together with realtime the way I want to do? Do you know any workarounds, such like setting a default state or changing the state manually when a device registers/unregisters?

Thanks for your help