[Home]

Summary:ASTERISK-24811: asterisk-publication sorcery object does not use realtime
Reporter:Matt Hoskins (mhoskins)Labels:
Date Opened:2015-02-19 10:28:00.000-0600Date Closed:2015-02-21 18:42:45.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_publish_asterisk
Versions:13.2.0 Frequency of
Occurrence
Related
Issues:
Environment:ubuntu64 14.04Attachments:( 0) res_pjsip_publish_asterisk.c.patch
Description:When configuring res_pjsip_publish_asterisk to use realtime in sorcery.conf, the module continues to use pjsip.conf.  The expected behavior is to use the realtime system, defined in extconfig.

Comments:By: George Joseph (gjoseph) 2015-02-19 11:54:56.731-0600

Matt, can you give me a config I can test with and some expected results?

By: Matt Hoskins (mhoskins) 2015-02-19 12:14:15.233-0600

Sure, no problem.

The intended configuration is this:

{code:title=/etc/asterisk/sorcery.conf}

[res_pjsip_publish_asterisk]
asterisk-publication=realtime,ps_asterisk_publication

{code}

{code:title=/etc/asterisk/extconfinf.conf}
ps_asterisk_publication => odbc,asterisk-realtime
{code}

{code:title=/etc/asterisk/res_odbc.conf}
[asterisk-realtime]
enabled => yes
dsn => asterisk-realtime-connector
pooling => yes
limit => 5
pre-connect => yes
{code}

With a mysql table with the following configuration:

{code:sql}
CREATE TABLE `ps_asterisk_publication` (
`id` varchar(80) NOT NULL,
`devicestate_publish` varchar(40) DEFAULT NULL,
`mailboxstate_publish` varchar(40) DEFAULT NULL,
`device_state` enum('yes','no') DEFAULT 'no',
`mailbox_state` enum('yes','no') NOT NULL DEFAULT 'no',
`device_state_filter` varchar(80) DEFAULT NULL,
`mailbox_state_filter` varchar(80) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
{code}

With that configuration, When a SIP PUBLISH command is sent, asterisk responds with a 404 NOT FOUND:

<--- Received SIP request (582 bytes) from UDP:10.160.212.103:5060 --->
PUBLISH sip:dev-ast-voicemail@dev-ast-ep1.npgco.com SIP/2.0
Via: SIP/2.0/UDP 10.160.212.103:5060;rport;branch=z9hG4bKPj97dca5b7-d4cf-46eb-9a3e-f8f66396adcb
From: <sip:dev-ast-voicemail@dev-ast-ep1.npgco.com>;tag=2a727827-f518-408c-b6e5-809cc1ef4cab
To: <sip:dev-ast-voicemail@dev-ast-ep1.npgco.com>
Call-ID: 5e11ae28-7cfd-4e8d-8d4e-970cfcb843a0
CSeq: 55987 PUBLISH
Event: asterisk-devicestate
Expires: 3600
Content-Type: application/json
Content-Length:   110

{"cachable":1,"device":"PJSIP/dev-ast-ep1","type":"devicestate","state":"NOT_INUSE","eid":"08:00:27:06:97:2c"}
<--- Transmitting SIP response (434 bytes) to UDP:10.160.212.103:5060 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 10.160.212.103:5060;rport=5060;received=10.160.212.103;branch=z9hG4bKPj97dca5b7-d4cf-46eb-9a3e-f8f66396adcb
Call-ID: 5e11ae28-7cfd-4e8d-8d4e-970cfcb843a0
From: <sip:dev-ast-voicemail@dev-ast-ep1.npgco.com>;tag=2a727827-f518-408c-b6e5-809cc1ef4cab
To: <sip:dev-ast-voicemail@dev-ast-ep1.npgco.com>;tag=z9hG4bKPj97dca5b7-d4cf-46eb-9a3e-f8f66396adcb
CSeq: 55987 PUBLISH
Content-Length:  0


However, if I use the attached patch, I receive a 200 OK and the devicestate and mwi are processed properly


By: Matt Hoskins (mhoskins) 2015-02-19 12:14:55.018-0600

possible patch to make res_pjsip_publish_asterisk use sorcery realtime.

By: Matt Hoskins (mhoskins) 2015-02-19 12:22:08.598-0600

I added some comments, not sure if I should have done that here, or not.  I'm new to JIRA. :)

By: George Joseph (gjoseph) 2015-02-19 12:30:08.785-0600

The missing ast_sorcery_apply_config() is the culprit and I have a patch ready for that.  Why did you comment out the reload?

By: Matt Hoskins (mhoskins) 2015-02-19 12:49:58.005-0600

Heh, out of pure ignorance.  I literally copied the logic out of res_pjsip_pubsub.c and noticed that it did not have a reload section.

By: George Joseph (gjoseph) 2015-02-19 13:01:53.432-0600

Matt, can you test the patch from
https://reviewboard.asterisk.org/r/4433/
and let me know.


By: Matt Hoskins (mhoskins) 2015-02-19 13:20:20.540-0600

Tested and I'm now getting the expected results.  Thanks!

2 quick questions, if you don't mind:

Why the difference between creating a sorcery object and referring to it which each call vs using ast_sip_get_sorcery()?

Also, the documentation at https://wiki.asterisk.org/wiki/display/AST/Exchanging+Device+and+Mailbox+State+Using+PJSIP is wrong.  It references using the 'endpoint' option on the asterisk-publication object, but that's not a valid option.  I'd be happy to update that page with an additional set of pages to include using realtime configuration for SIP events.

By: George Joseph (gjoseph) 2015-02-19 13:35:21.810-0600

ast_sip_get_sorcery() is just a wrapper around the res_pjsip sorcery instance.  It optimizes itself away and just saves the step of having to assign the sorcery instance pointer to a local variable.  That being said, we're not very consistent about it.  :)

Wiki updates would be most appreciated.  You might want to add some comments to the page first and get some feedback.

I'm going to note in the review that you tested successfully if that's OK.


By: Matt Hoskins (mhoskins) 2015-02-19 13:42:25.737-0600

Sounds great.  Thanks again for your quick replies.  While I didn't actually commit code, I feel like I contributed. :)