Asterisk 1.8 package
-
Bug and fix
I just found and fixed a bug in /usr/local/pkg/asterisk.inc (v0.3.1, not latest).
Symptom:
Every time the Asterisk package is started, the following files in /conf/asterisk are modified:
asterisk.conf
logger.confEdits that the user has made to these files may be lost (if they overlap the modifications
performed by asterisk.inc).Description:
These files are supposed to be modified the FIRST time that the Asterisk package is started.
When asterisk.inc modifies other .conf files it adds a flag comment '; by pfSense ;' .
The flag comment is present in logger.conf, missing in asterisk.conf.
The code in asterisk.inc doesn't, but should, check for presence of the flag comment in these two files and not modify them if the flag comment is present.Fix:
In asterisk.inc:
1. Add flag comment to asterisk.conf when modifying it.
2. Do not modify asterisk.conf or logger.conf if the file already contains the flag comment.I have attached a .zip with both a unified context diff and the full file (patched), whichever you prefer to work with.
Remember, this is for package v0.3.1 (what I'm running).
The file asterisk.inc has changed since then. -
Any patches need to go to https://github.com/pfsense/pfsense-packages/ and obviously need to be against current code. Just a note.
-
res_fax.so and res_fax_spandsp.so
Hi,
the package contains res_fax.so, but not res_fax_spandsp.so. Is there a specific reason why this lib does not exits?I have a native build for res_fax_spandsp.so, but this does not seem to work (libspandsp does not seem to be able to find libjpeg, although it is also in /usr/local/lib).
-
res_fax.so and res_fax_spandsp.so
I found the place where to put symlinks for the missing libaries.
Now I have the following problem
[Oct 16 20:56:18] WARNING[-1]: loader.c:835 inspect_module: Module 'res_fax_spandsp.so' was not compiled with the same compile-time options as this version of Asterisk. [Oct 16 20:56:18] WARNING[-1]: loader.c:836 inspect_module: Module 'res_fax_spandsp.so' will not be initialized as it may cause instability. [Oct 16 20:56:18] WARNING[-1]: loader.c:923 load_resource: Module 'res_fax_spandsp' could not be loaded.
The basic reason could be that the versions of Asterisk and the module are different: 1.8.32 vs. 1.8.x. I compiled Asterisk from the ports directory of the current 10.1 version, so I cannot arbitrarily choose the version.
-
I am currently working with the Asterisk package, where I am using pfSense/Asterisk essentially as a session border controller.
T.38 facsimiles are now working for me, which essentially involves patching the AST_BUILDOPT_SUM string inside the res_fax_spandsp.so lib. This is not really nice.
After restarting, some configuration files seem to get modified every time. There is some funny stuff that gets appended to modules.conf and extensions.conf. Does anyone know why this is happening?
After rebooting pfSense, there's also a problem with the SIP module on my box, which looks as if other network functions are not yet properly running. Waiting and restarting the Asterisk solves the problem
Is currently someone working on this package? I have some spare time to work on the package.
-
1/ You do NOT make changes to config files via shell. They get lost. You configure things via GUI. If it's not possible, modify the GUI code and submit a pull request against the current code… Not outdated one that noone can install. Useless.
2/ You do not produce any similar nonsense like binary patches mixing libraries from different binary packages. That has nothing to do with "work on the package". Noone will merge such crap.
3/ About 99% of the world abandoned junk like fax ages ago. Hardly surprising noone tests it.
4/ Before wasting time on trying to fix unfixable crap such as PBI, perhaps rather play with pfSense 2.3 and get it working there.P.S. My personal observation: There's tons of whole LOT more suitable places to run a PBX on. Such as some VM on a DMZed server. Frankly, why anyone thinks putting this monster on their firewall is a good idea goes beyond me. Especially when a VM-ready appliance incl. a configuration GUI is readily available for download! http://www.asterisk.org/downloads/asterisknow
-
@doktornotor - Maybe you don't know what the role of an SBC is. An SBC is not a PBX, although the package may be the same…
-
RTCP stats problem
CLI command 'sip show channelstats' issued during an active call: all data except duration is zero.
I've done 'rtcp set stats on'.
I've turned on rtcp debug: I get Sender Reports from both my endpoint and my provider's SIP proxy.Just wondering:
Where does Asterisk store the RTCP stats? Memory? Disk? If disk, does the Asterisk init script need to create another directory under /var?Thanks!
EDIT:
The problem is due to this Asterisk 1.8 open bug:https://issues.asterisk.org/jira/browse/ASTERISK-18455
I temporarily forced Asterisk to transcode and I started getting valid data from 'sip show channelstats'.
-
There might be a different cause. Please check the value of directmedia in sip.conf. The default setting is "yes", where Asterisk tries to redirect media directly between caller and callee. In this case Asterisk doesn't see any audio and hence cannot generate any statistics.
-
In sip.conf all of my device definitions include directmedia=no, so that's not it.
But thanks for the suggestion. -
The current Asterisk package generates an rc-file named asterisk.sh. This causes the service to get started two times in rc.start_packages, because the second instance cannot check that another instance is already running. It takes a moment before the pid file has been generated.
The package should generate a simple rc-file with the name asterisk, such that the manual boot time service does not get called.
-
The package should generate a simple rc-file with the name asterisk, such that the manual boot time service does not get called.
What second instance? The /usr/local/etc/rc.d/asterisk script is removed on install.
https://github.com/pfsense/pfsense-packages/blob/master/config/asterisk/asterisk.inc#L41
-
Nope, the file asterisk never gets generated, only asterisk.sh. And this causes the problem of two instances.
-
Nope, the file asterisk never gets generated, only asterisk.sh. And this causes the problem of two instances.
And it should NOT get generated. The only file that SHOULD exist is asterisk.sh. If you still have /usr/local/etc/rc.d/asterisk, just reinstall the package. (And, in general, do yourself a favor and do not upgrade packages on pfSense <2.3, uninstall and reinstall them instead. Otherwise, the updated install code simply is not used.)
-
I think currently only asterisk.sh gets installed. asterisk.sh causes problems. I have to setup a new box tomorrow and then I'll have a look at what happens at a fresh install.
<service>.sh should only be used for manual services outside any package. At least that's my understanding. Just have a look at rc.start_packages. Essentially $rcfiles = glob(RCFILEPREFIX . "*.sh"); grabs all .sh files and if a package uses the .sh extension itself; one potentially runs into problems if an executable cannot detect that another instance has already been started.</service>
-
Sigh.
1/ <service>.sh is used by pretty much any package out there. Usually generated by write_rcfile(). The scripts bundled with the PBI packages are NOT usable.
2/ As already noted 3 times, you should NOT have any /usr/local/etc/rc.d/asterisk script in there. If you have, then delete it or reinstall the package and it will delete is on install.</service> -
The asterisk script is not generated, only asterisk.sh, but this script is called two times during system startup. Since Asterisk cannot detect almost parallel invocations, two instances are typically running. That's a problem. Therfore I suggested to give the first invocation a chance to get fully booted.
If you don't believe me, insert a "logger" statement in asterisk.sh to see that "start" it is called twice at system startup.
-
FFS!!!! Your issue is having TWO scripts when you should have one, and that one should be called asterisk.sh. Reinstall the package or delete it manually. Explained 4 times by now. >:(
Period.
-
There's only asterisk.sh, and this script gets called twice.
-
Yeah, so get it fixed in pfSense core. Every damn package out there uses what I already explained.
-
Hoops! There was an "asterisk" script withoug the .sh extension…
-
Incredible. Won't explain for the fifth time. Pretty much every package out there uses <something>.sh with no problem. If you have issue with something called twice, then fix the code that's calling something twice.
And - while here… that pfSense core code show grow itself some brain and produce an API for disabling packages. Instead of people hacking code that creates the script on enabling the package and remove it on disabling. rc.conf.local ain't usable for this, perhaps/etc/rc.conf.d/ could.</something>
-
I just started a fresh 2.2.5 install (virtual machine) and the default installation starts Asterisk twice as described here:
https://forum.pfsense.org/index.php?topic=102591.0
asterisk.sh gets called twice and there are no old installations and there is no single asterisk script in the rc.d dir. A couple of days ago I added a logger() statement in asterisk.sh and the script was indeed called twice, which explains the two instances.Tomorrow I'll setup a new machine and then I'll report again. I have about half a dozen 2.2.4 boxes with older installations, so I cannot exclude that there are still asterisk scripts or whatever, like the one I checked about an hour ago.
-
Initially asterisk.sh gets called in the background and the .sh loop calls it directly, so a short sleep may or may not solve the problem.
I am too tired now, but my basic idea is that anything that gets called in the background with start_service(), will not get called subsequently. Should be easy to implement.
-
I am too tired now, but my basic idea is that anything that gets called in the background with start_service(), will not get called subsequently. Should be easy to implement.
Kindly post the output of the following (paste to Diagnostics - Command Prompt - PHP execute)
require_once("/etc/inc/pkg-utils.inc"); $rcfiles = glob(RCFILEPREFIX . "*.sh"); if (!$rcfiles) $rcfiles = array(); else { $rcfiles = array_flip($rcfiles); if (!$rcfiles) $rcfiles = array(); } if (is_array($config['installedpackages']['package'])) { foreach($config['installedpackages']['package'] as $pkgid => $package) { $internal_name = get_pkg_internal_name($package); unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]); } } var_dump($rcfiles);
since whatever you are describing simply doesn't happen with sane configuration. The .sh script just won't run from the $shell = @popen("/bin/sh", "w"); part because it's unset with the
unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]);
line.
-
https://github.com/pfsense/pfsense-packages/pull/1191 should fix whatever is fixable in the package regarding service (re)starts.
-
Kindly post the output of the following (paste to Diagnostics - Command Prompt - PHP execute)
I see this only briefly flashing on the console. Are these messages also written into some file?
-
Console?! Diagnostics - Command Prompt - PHP execute is not briefly flashing anywhere. Regardless, the PR has been merged.
-
One can call log_error() to show things on the console, which I used for my tests. I also saw a couple of echos in rc.start_packages, but I did not check where the output is going (probably nowhere, without a web interface). The same would apply to your var_dump() call.
I could explicitly call rc.start_packages and rc.stop_packages, but I don't know whether this is equivalent to what happens at boot time. It will take some time before I've studied all the php stuff….
-
I would suggest installing 0.3.4 before wasting more time here.
-
Can the Asterisk package meanwhile work as an endpoint for T.38 faxes? No? My custom package does. There's nothing in the GUI that depends on the specific Asterisk version, so why is 1.8 used? No hangup handlers, no named ACLs, no AMI security events, no RESTful interface, but a lot of useless modules. Maybe it is you who should not waste time with Asterisk. Have you figured out meanwhile why a B2BUA makes sense in a firewall?
-
Dude, I have no clue why are you aiming your rants at me. You can test with 0.3.4 to see whether your "started twice on boot" issue is fixed.
-
I'd like to suggest a small patch for /usr/local/etc/rc.d/asterisk.sh, actually for the sync_package_asterisk function in /usr/local/pkg/asterisk.inc.
In line 396 in asterisk.inc add
if [ ! -e /var/db/asterisk/astdb ] && [ -e /cf/conf/asterisk/astdb.backup ]; then cp /cf/conf/asterisk/astdb.backup /var/db/asterisk/astdb chown asterisk:asterisk /var/db/asterisk/astdb chmod 0775 /var/db/asterisk/astdb fi
Then add after line 408:
$stop .= "\n\tif [ -e /var/db/asterisk/astdb ]; then\n\t"; $stop .= "\tcp -f /var/db/asterisk/astdb /cf/conf/asterisk/astdb.backup\n\tfi;"
The associated patch would be:
396a397,402 > if [ ! -e /var/db/asterisk/astdb ] && [ -e /cf/conf/asterisk/astdb.backup ]; then > cp /cf/conf/asterisk/astdb.backup /var/db/asterisk/astdb > chown asterisk:asterisk /var/db/asterisk/astdb > chmod 0775 /var/db/asterisk/astdb > fi > 402a409,410 > $stop .= "\n\tif [ -e /var/db/asterisk/astdb ]; then\n\t"; > $stop .= "\tcp -f /var/db/asterisk/astdb /cf/conf/asterisk/astdb.backup\n\tfi;"
The additions save and restore the astdb file when Asterisk gets stopped or restarted. For convenience, I selected the /cf/conf/asterisk directory, such that it gets saved with the configuration backup command.
The background of this patch is to make Asterisk work properly when RAM disks are used (Advanced->Miscellaneous). Asterisk itself always tries to use astdb, regardless of whether app_db, or func_db are loaded, and tries to keep track of current registrations across program invocations. Otherwise, phones have to register again before they can be used. Typical registry expiry times are 1h, so this could be a problem in larger installations. At home one would simply restart the phones, I guess.
-
Asterisk 0.3.4 does not start from GUI
New install of pfSense nanoBSD 2.2.5
Restore last config from 2.2.4, which had Asterisk 0.3.1 installed
Asterisk 0.3.4 gets installed automatically
Asterisk does not start
Asterisk can't be started manually from Status->Services
Asterisk can be started manually via ssh:
/usr/local/etc/rc.d/asterisk.sh startLong story short
–-------------------v0.3.1 asterisk.xml service definition defined rcfile as "asterisk"
v0.3.4 asterisk.xml service definition defines rcfile as "asterisk.sh" : correct
After restoring config where rcfile was "asterisk" and installing v0.3.4 (in that order), config.xml service definition still defines rcfile as "asterisk", i.e., the old service definition isn't updated when v0.3.4 is installed.Workaround: Edit config.xml manually, changing asterisk rcfile definition from "asterisk" to "asterisk.sh". Then delete /tmp/config.cache.
This workaround shouldn't need to be repeated in the future.I don't know why config.xml isn't being updated when v0.3.4 is installed.
-
I don't know why config.xml isn't being updated when v0.3.4 is installed.
Because the install code is cached in various broken ways… General hint: Do not upgrade packages on pfSense <2.3; uninstall + reinstall the new version.
-
Hi,
Is there any HOWTO for newbie telling how to start using the asterisk on pfsense?
I installed the package and started it, but there are a lot of config files …I am complete newbie in the ASTERISK, I am just a user of PFSense. All VoIP phones I use connect to external VoIP provider, which is not very optimal.
I would like to test asterisk and maybe in the feature instead of configure my phones to use external provider I would go for having VoIP PBX in my LAN.
But have no idea where to start.Please give me some advice.
Thanks
-
You'll have to deal mostly with sip.conf and extensions.conf, only. Maybe you want to play a bit with modules.conf.
I'd recommend
http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/index.html
to start with and I'd set up a virtual machine for initial explorations and not use the pfSense package.The Asterisk package for pfSense does not really have a GUI, you need to edit the configuration files manually, but the benefit is that this is much more flexible.
-
Hi Marcello!
First of all I want to thank you for this nice pfSense package. I installed it on the latest release of nanoBSD based 64Bit pfSense (embedded on a 4GB USB flash drive).Currently 2 sip trunks were configured, asterisk is using the also installed siproxd (package version 1.0.9).
Although everything is working fine, there are warning messages in the asterisk log:
[2.2.6-RELEASE][admin@pfsense.sm.art]/root: asterisk -r Asterisk 1.8.32.1, Copyright (C) 1999 - 2013 Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk 1.8.32.1 currently running on pfsense (pid = 97717) [Jan 29 17:18:36] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:18:36] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:26:21] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:26:21] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:34:07] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:34:07] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:41:52] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:41:52] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:49:37] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:49:37] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:57:22] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 17:57:22] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:05:07] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:05:07] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:12:52] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:12:52] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:20:37] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:20:37] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:28:22] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Jan 29 18:28:22] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect pfsense*CLI></markster@digium.com>
Issue summary:
-
Annoying warning message: WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect
-
Exactly one message every 585 seconds for every configured sip trunk! Very mysterious fact.
-
No IP traffic to & from asterisk during this time! (checked with wireshark and pfsense packet capturing)
-
Is spamming the logfile over the time.
-
Everything else is working perfect: incoming and outgoing calls are ok.
Does anybody also have this annoying message? Or any hints for me for further debugging? The 585 seconds must be hardcoded anywhere.
Thanks in advance.
-
-
ouraddrfor() is related to IP lookup. Unless there are other errors or warnings your warning could be related to a not properly working DNS server configuration.
-
Mmmh. This are the only warning message I get from asterisk. DNS is properly configured. But I found a good hint in the net:
https://reviewboard.asterisk.org/r/2851/
I use siproxd as my outboundproxy. So outboundproxy is set to my local siproxd. And according to the above review asterisk does not do any DNS resolutions when outboundproxy is set. See the column "dnsmgr":
Connected to Asterisk 1.8.32.1 currently running on pfsense (pid = 61232) pfsense*CLI> core reload [Feb 3 17:36:53] NOTICE[-1]: pbx_lua.c:1530 load_or_reload_lua_stuff: Lua PBX Switch loaded. [Feb 3 17:36:53] NOTICE[-1]: app_queue.c:6867 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action. [Feb 3 17:36:53] NOTICE[-1]: cel_custom.c:95 load_config: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs. [Feb 3 17:36:54] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect [Feb 3 17:36:54] WARNING[-1]: acl.c:719 ast_ouraddrfor: Cannot connect pfsense*CLI> sip show registry Host dnsmgr Username Refresh State Reg.Time proxy.live.sipgate.de:5060 N 9999999e2@si 465 Registered Wed, 03 Feb 2016 17:36:54 tel.t-online.de:5060 N 03099999999 465 Registered Wed, 03 Feb 2016 17:36:54 2 SIP registrations.
As a test I let asterisk do its register direct without siproxd. Now there are no more "Cannot connect" warnings from ast_outaddrfor and dns resolution is set to "Y":
pfsense*CLI> core reload [Feb 3 17:35:45] NOTICE[-1]: pbx_lua.c:1530 load_or_reload_lua_stuff: Lua PBX Switch loaded. [Feb 3 17:35:45] NOTICE[-1]: app_queue.c:6867 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action. [Feb 3 17:35:45] NOTICE[-1]: cel_custom.c:95 load_config: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs. pfsense*CLI> sip show registry Host dnsmgr Username Refresh State Reg.Time proxy.live.sipgate.de:5060 Y 9999999e2@si 465 Registered Wed, 03 Feb 2016 17:35:46 tel.t-online.de:5060 Y 03099999999 465 Registered Wed, 03 Feb 2016 17:35:46 2 SIP registrations.
I think I have a catch-22 situation. Ok, I can ignore the warnings.
Has anyone some more ideas?