SIP Realtime Peers

Home » Asterisk Users » SIP Realtime Peers
Asterisk Users 4 Comments

Hi.

I’m using MariaDB (via ODBC) to store realtime SIP peers with Asterisk 13 and
16.

In general it’s all working fine, however there’s something that puzzles me:

If I connect to the Asterisk console and use the command “sip show peers” I
get a list of the peers including the last qualify time in the “Status”
column. The “Realtime” column tells me “Cached RT”.

Some of my peers are in the same data centre as the server I’m querying, and generally show a qualify time of 1ms; some are in another data centre and have qualify times around 15ms.

However, if I go to my database server and ask “select * from sippeers” I get the same list of peers but the “lastms” field is always zero. I had expected this to show me the last qualify time in milliseconds for each peer.

Am I just totally misinterpreting what “lastms” means in the table, or do I
need to do something else to get this value to reflect what Asterisk itself will tell me?

Thanks,

Antony.


“The tofu battle I saw last weekend was quite brutal.”

– Marija Danute Brigita Kuncaitis

Please reply to the list;
please *don’t* CC me.

4 thoughts on - SIP Realtime Peers

  • I’ve done a little more investigating, and from both documentation and the source code I’ve established that this field should be getting updated provided that “rtupdate” is set to “yes” in sip.conf, however as that is the default and I have not set it to “no”, I had expected the value indeed to be “yes”.

    Setting it explicitly to “yes” makes no difference.

    The totally unexpected part, though, is that if I modify the value of “lastms”
    in the database table, and then just wait about 30 seconds, Asterisk changes all the values back to zero.

    So, Asterisk definitely *is* updating this field in the database table; it’s just not using the correct values.

    Can anyone please comment on whether this is the bug it looks like to me, or whether I’m just missing some configuration setting which would make this work as expected?

    Thanks,

    Antony.


    BASIC is to computer languages what Roman numerals are to arithmetic.

    Please reply to the list;
    please *don’t* CC me.

  • Hi.

    Has nobody else tried to do this, or worked out how to (or, possibly, reported it as a bug)?


    Atheism is a non-prophet-making organisation.

    Please reply to the list;
    please *don’t* CC me.

  • I have found a totally weird method of getting this working.

    I simply need to add another field to the sippeers database table.

    Here’s the table definition as I’ve been using it for months:

    CREATE TABLE `sippeers` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `DDI` varchar(32) NOT NULL DEFAULT ”,
    `name` varchar(80) NOT NULL DEFAULT ”,
    `type` enum(‘user’,’peer’,’friend’) NOT NULL DEFAULT ‘peer’,
    `fromuser` varchar(80) DEFAULT NULL,
    `defaultuser` varchar(80) NOT NULL DEFAULT ”,
    `host` varchar(31) NOT NULL DEFAULT ‘dynamic’,
    `secret` varchar(80) DEFAULT NULL,
    `ipaddr` varchar(45) NOT NULL DEFAULT ”,
    `port` mediumint(5) unsigned NOT NULL DEFAULT ‘0’,
    `insecure` varchar(20) DEFAULT NULL,
    `context` varchar(50) DEFAULT NULL,
    `regseconds` int(11) NOT NULL DEFAULT ‘0’,
    `fullcontact` varchar(80) NOT NULL DEFAULT ”,
    `callbackextension` varchar(250) DEFAULT NULL,
    `regserver` varchar(100) NOT NULL DEFAULT ”,
    `useragent` varchar(50) NOT NULL DEFAULT ”,
    `lastms` int(11) NOT NULL DEFAULT ‘0’,
    `qualify` char(3) DEFAULT ‘no’,
    PRIMARY KEY (`id`),
    KEY `name_2` (`name`)
    ) ENGINE=InnoDB AUTO_INCREMENT=13862017 DEFAULT CHARSET=utf8mb4

    If I do the following:

    alter table sippeers add column anything int after qualify;

    (I’ve called the column “anything” to emphasise that the name appears to be entirely unimportant)

    then all of a sudden, the lastms field contains useful and sensible values.

    Is this a bug, or is there something wrong with my original table definition?

    Antony.


    Police have found a cartoonist dead in his house. They say that details are currently sketchy.

    Please reply to the list;
    please *don’t* CC me.

  • This turns out not to be reliable – sometimes the numbers all go back to zero, but at least it works some of the time, which I’ve never achieved before.


    The next sentence is untrue. The previous sentence is true.

    Please reply to the list;
    please *don’t* CC me.