[Home]

Summary:ASTERISK-24474: sip_to_pjsip.py lacks documentation and does not function
Reporter:John Kiniston (johnkiniston)Labels:
Date Opened:2014-10-30 18:53:42Date Closed:2015-01-09 16:11:01.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Contrib/General
Versions:13.0.0-beta3 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:
Description:This is actually an issue against 13.0.0 however it is not listed in the Version dropdown.

I assume I run sip_to_pjsip.py from /etc/asterisk with the input and output file as arguments as there are no instructions for this tool.

The tool also appears to not work, Despite what the below error states I do have a udpbindaddr set to 0.0.0.0  in my configuration.
{noformat}
root@kiniston01:/etc/asterisk# /usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py sip.conf pjsip.conf
Traceback (most recent call last):
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 1158, in <module>
   pjsip, non_mappings = convert(sip, pjsip_filename, dict(), False)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 1090, in convert
   map_transports(sip, pjsip, nmapped)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 817, in map_transports
   create_udp(sip, pjsip, nmapped)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 590, in create_udp
   bind = sip.multi_get('general', ['udpbindaddr', 'bindaddr'])[0]
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/astconfigparser.py", line 407, in multi_get
   (key_list, section))
LookupError: keys ['udpbindaddr', 'bindaddr'] not found for section 'general'
{noformat}
I have tried it with the sip.conf.sample file and receive the same error:
{noformat}
www:/tmp# /usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py sip.conf pjsip.conf
Traceback (most recent call last):
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 1158, in <module>
   pjsip, non_mappings = convert(sip, pjsip_filename, dict(), False)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 1090, in convert
   map_transports(sip, pjsip, nmapped)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 817, in map_transports
   create_udp(sip, pjsip, nmapped)
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py", line 590, in create_udp
   bind = sip.multi_get('general', ['udpbindaddr', 'bindaddr'])[0]
 File "/usr/src/asterisk-13.0.0/contrib/scripts/sip_to_pjsip/astconfigparser.py", line 407, in multi_get
   (key_list, section))
LookupError: keys ['udpbindaddr', 'bindaddr'] not found for section 'general'
{noformat}
Comments:By: Rusty Newton (rnewton) 2014-11-05 13:39:00.721-0600

I can confirm. Also, yeah there isn't really other documentation than the usage with -h.

{noformat}
Usage: sip_to_pjsip.py [options] [input-file [output-file]]

input-file defaults to 'sip.conf'
output-file defaults to 'pjsip.conf'

Options:
 -h, --help            show this help message and exit
 -p PREFIX, --prefix=PREFIX
                       output prefix for include files
{noformat}

We should add some examples of usage and results on the wiki. Also perhaps a short description of what the tool does in the -h help.

By: Matt Jordan (mjordan) 2014-12-23 11:12:16.866-0600

[~johnkiniston]: There's a patch now up on review board that should fix the exception. Do you mind running it through your {{sip.conf}} and see if it fixes the exception you ran into?

By: John Kiniston (johnkiniston) 2014-12-23 12:03:52.660-0600

I have re-run the patched script, I am no longer getting an exception.

It's creating a pjsip.conf file now however the contents are nearly empty.

;--
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Non mapped elements start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Non mapped elements end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--;


[transport-udp]
type = transport
protocol = udp
bind =


By: Scott Griepentrog (sgriepentrog) 2014-12-29 07:53:01.700-0600

As it doesn't interpret the comments, that would be the expected output.

By: Frederic Steinfels (fredo) 2015-10-15 05:37:37.990-0500

How can this script lack the functionality to strip the comments and just fail miserably without any warning? Anyway, I used this to preprocess sip.conf into an acceptable form (please remove the newlines, its all on in one line):

cat sip.conf | awk -F\; '$1!="" { print $1 ;} ' > sip.conf2

By: Alexander Traud (traud) 2016-09-05 08:25:55.308-0500

[~johnkiniston], are you about the file {{./configs/samples/sip.conf.sample}}? If yes, that is the expected output because everything is commented in the sample file. However, if you are about your personal configuration and still face any issue, please, create a new issue report.

[~fredo], the script should remove comments within your {{sip.conf}} and continue to migrate to {{pjsip.conf}}. If that does not work in your case – I am not able to reproduce this issue yet – you found a software bug, for sure. Last month, there was a change in the configuration parser [related to comments|https://github.com/asterisk/asterisk/commits/13/contrib/scripts/sip_to_pjsip/astconfigparser.py]. Please, give it a try:
{noformat}cd ~/Downloads/
git clone --branch 13 http://gerrit.asterisk.org/asterisk
cd /etc/asterisk/
sudo ~/Downloads/asterisk/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py{noformat}

@All, the Asterisk Wiki contains a page about [migrating from chan_sip to re_pjsip|https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip], now. If you still face any issues with the migration script, please, create a new issue report.