[Home]

Summary:ASTERISK-21315: Asterisk Realtime using res_config_mysql not recognizing port field for SIP peers
Reporter:Eugene Voityuk (eugene.voityuk)Labels:
Date Opened:2013-03-25 13:32:09Date Closed:2013-05-22 14:06:47
Priority:MinorRegression?
Status:Closed/CompleteComponents:Addons/res_config_mysql PBX/pbx_realtime
Versions:1.8.20.1 Frequency of
Occurrence
Related
Issues:
Environment:MySQL: Server version: 5.1.67-log Source distribution CentOS release 6.4 (Final) Asterisk 1.8.20.1 built by root @ distro-el6.asterroid.com on a x86_64 running Linux on 2013-03-13 10:10:51 UTCAttachments:
Description:So basicly, i have MySQL database to which my asterisk is connected, all works fine, for example i am creating trunk and it is workable, but the "port" option always load 5060(default value), even if i specify there another. from file everything works fine.

[edit by Rusty Newton - adding reproduction info from reporters comment below]

{quote}
You need to have mysql table(sip_users), with all fields, in column port setup default value 5060, then create sip peer with port setuped to 5068(for example), in extconfig.conf write:
sipusers => mysql,pbxconf,sip_users
sippeers => mysql,pbxconf,sip_users
reload configuration, peer will become visible, but the port will be set to 5060 not the one that you have for the peer.
If i am using sip.conf instead of DB it's works just fine, but i need DB.
No this is not the bindport in sip.conf
{quote}
Comments:By: Rusty Newton (rnewton) 2013-03-29 09:51:49.033-0500

Please read through: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines

Please describe how to reproduce this.

Are you trying to change the chan_sip SIP binding port in realtime?

Are you setting the SIP port in sip.conf ?

Please give an example of what you are doing so that we can understand exactly how to reproduce the issue.

By: Eugene Voityuk (eugene.voityuk) 2013-03-29 11:11:10.283-0500

You need to have mysql table(sip_users), with all fields, in column port setup default value 5060, then create sip peer with port setuped to 5068(for example), in extconfig.conf write:
sipusers => mysql,pbxconf,sip_users
sippeers => mysql,pbxconf,sip_users
reload configuration, peer will become visible, but the port will be set to 5060 not the one that you have for the peer.
If i am using sip.conf instead of DB it's works just fine, but i need DB.
No this is not the bindport in sip.conf  

By: Rusty Newton (rnewton) 2013-04-08 19:03:25.982-0500

Can you verify this does not happen when using a backend other than res_config_mysql backend for realtime? Preferably if you can test the core supported res_config_odbc that would be helpful.

res_config_mysql is under extended support and therefore is supported by the community, response times may reflect that.

You may want to add a sanitized table dump so a developer can see the exact settings you have in use for the sip peers.

Getting an Asterisk debug log with VERBOSE and DEBUG at level 5 showing during a configuration reload may be helpful.


By: Eugene Voityuk (eugene.voityuk) 2013-05-20 05:21:37.160-0500

Hi there! Sorry for the late response.. I found what was the problem... We was using separate table for sip_regs, and that table was created as static table with stored procedures, but the sip_regs table should be a VIEW from sip_users table, then everything work just fine. Thank you very much, is there any way to add this information to your Wiki page?

By: Walter Doekes (wdoekes) 2013-05-20 06:46:18.199-0500

You should avoid using sipregs altogether. Using a writable sipusers table should be enough.

If you cannot write to your base sipusers table because it is readonly, you could consider making a separate sipusers view that joins the readonly table with a writable sipregs table.

By: Rusty Newton (rnewton) 2013-05-22 14:06:47.636-0500

Documented the helpful tips above on the wiki [here|https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration#RealtimeDatabaseConfiguration-Notesonuseofthesipregsfamily]

By: Eugene Voityuk (eugene.voityuk) 2013-05-22 14:18:36.665-0500

Here is required fields:

CREATE VIEW `sipregs` AS SELECT
   `id`
   ,`name`
   ,`ipaddr`
   ,`port`
   ,`regseconds`
   ,`defaultuser`
   ,`fullcontact`
   ,`regserver`
   ,`useragent`
   ,`lastms`
FROM `sippeers`;

By: Rusty Newton (rnewton) 2013-05-22 19:03:49.508-0500

Thanks I added that as well. You should be able to comment on the wiki page if you have any further suggestions.

By: Walter Doekes (wdoekes) 2013-05-23 03:03:59.479-0500

I edited that. It's now uglier but less wrong.

The sipregs table is a good idea. Having a writable table separate from the readonly details is good.
Unfortunately due to the database abstraction layer in asterisk (no joins), a decent implementation is impossible. It caused lots of extra queries and complexity (and bugs).

Therefore its usage is discouraged.

However, some people *do* have readonly details. In that case the recommended solution is to make a writable VIEW that joins the writable sipregs' and readonly sipusers' into a writable sipusers view. I.e. the database takes care of the necessary join and asterisk only needs to worry about a single table (sipusers).