Sip Trunk turns to "Rejected" and only Re-Registers after a reload

Hello Community,

we have some problems with a sip trunk.

After a few days the sip trunk goes into state

“Rejected”

and does not try to re-register anymore.

I already tried to set the option “register_retry_403=yes”, but this does not work in that case.

At the moment the only way is a

“fwconsole reload”

command to force a “re-register”.

Registration Attempts is already set to “0” and the timeout is set to 20.

So in the case of a “Rejected” there has to be done something other to force a re-register.

Can someone help me please? At the moment i wrote a script, which runs as a cronjob, that checks the registry state and forces a reload when the state “Rejected” occours, but this is not really a solution.

Hi Matthias,

Did you solve this issue?? I’m experimenting the same on one site, and need to reload to get registered again. And it normally happens on bad moments that you need to reload quickly to get poeple on the phone again.

I also se the register_retry_403 but didn’t solve it neither, and on the logs I have no info

kindest regards

Hi, pietervos,

i got some new trunk settings from my provider and had no issues in the past.

But for sure i wrote a Script which checks the connection every minute and reloads asterisk in the case of the state “Rejected”.
Maybe it is a workaround for you.

sudo touch /home/asterisk/reloadlog.txt

sudo nano /home/asterisk/checkregistry.php

add that:

<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
  include_once('/etc/asterisk/freepbx.conf');
}
if($astman->connected()) {
$out = $astman->Command('sip show registry');
echo $out['data'];
if (strpos($out['data'], 'Rejected') !== false) {
echo 'true';
$output = shell_exec('/sbin/fwconsole reload');
echo "<pre>$output</pre>";
file_put_contents("/home/asterisk/reloadlog.txt", (new \DateTime())->format('Y-m-d H:i:s') . "\n", FILE_APPEND);
}


} else {
echo "not asterisk manager connection";
}

Then this commands:

sudo chown asterisk:asterisk /home/asterisk/checkregistry.php
sudo chown asterisk:asterisk /home/asterisk/reloadlog.txt

Then make the cronjob as root user:
If you make the cronjob with the asterisk user, it can happen, that freepbx does not autostart anymore on boot if you use the SNG7 distro!

export VISUAL=nano; crontab -e

add the line:
* * * * * su asterisk -c "/usr/bin/php /home/asterisk/checkregistry.php" >/dev/null 2>&1

This is my workaround in the case that the trunk turns into “rejected”.

Asterisk will reload.

The reloadlog shows you when this happened.

I do not give any warranty for this. Use this at your own risk!!!

Hi Matthias

Thanks for your quick reply. I’ve setup your script, keeping an eye when it happens again.

When you got the “Rejected” status of the trunk, did you have any info logged in the asterisk log?? On my site the only issues I’ve seen was that the trunk was unreachable and afterwards reachable.

[2017-11-27 05:00:30] NOTICE[2289] chan_sip.c: Peer 'trunkxxx' is now UNREACHABLE!  Last qualify: 13
[2017-11-27 05:01:34] NOTICE[2289] chan_sip.c: Peer 'trunkxxx' is now Reachable. (11ms / 2000ms)

After this normally it’s rejected without any other notices.

Did the new trunk settings connect to the same trunk or did they change it completly??

I will give you some feedback to confirm script is working as soon I get a rejected!

Kindest regards and thanks for your help!

Pieter

Sorry i cannot remember the logs anymore. It is already over a month ago since i had the issues.

I changed my trunk settings. My incoming settings are completely empty now. Everything is set under “outgoing”.
The only incoming setting is the registry string.

The script just executes “fwconsole reload” and writes a timestamp into the logfile “reloadlog.txt” if there is a registry with the value “Rejected”. For me it worked.

By the way i strongly recommend you to use the Sangoma RMS Services!!! @tonyclewis am i right that the Sangoma RMS Service can monitor the trunks out of the box without any knowledge of developing plugins or something else?

Hi!

Looks like someone didn’t get the memo…

https://community.freepbx.org/t/rms-public-beta-coming-to-a-close-on-january-1-2018/45646

Sounds to me it is not yet certain they will bring it back as a commercial service and when…

Have a nice day!

Nick

ohh i missed that information. I thought RMS is already available to buy.

In my case i use omdistro with CheckMK and Nagios Plugins for Asterisk to monitor the PBX Systems.
But i do not recommend it to anyone else because the setup is not easy and you have to know how to work with nagios plugins.

However if someone wants to build his own monitoring Server, try your luck with the sources below.

Sources:
https://labs.consol.de/omd/
https://exchange.nagios.org/directory/Plugins/Telephony/Asterisk
http://smstools3.kekekasvi.com/


1 Like

@pietervos

You need to change the crontab from the Script. I had an issue today.
The Script worked as it should and putted an entry into the reloadlog file.
But the fwconsole reload command did not work from crontab.

Here is the working crontab:

run:
export VISUAL=nano; crontab -e

Crontab:
* * * * * su asterisk -c "/usr/bin/php /home/asterisk/checkregistry.php" >/dev/null 2>&1

Hi @mitterhuemer , thanks for the update. The last weeks it seems to be working without any incident until yesterday, and your script did the work properly!

(I had to change /sbin/fwconsole to /bin/fwconsole as the distro I’m using has a different path)

Still wondering why this is happening.

Kindest regards

1 Like

I will maybe write a module for this.

My provider says this is a asterisk bug. Asterisk looses the connection and then it does not send the password anymore inside the registry string until the next kernel reload.

The provider sent me his logfiles.

Dec 11 10:05:25 spce proxy[29846]: NOTICE: <script>: Authentication failed, no credentials - R=sip:sip.myprovider.at ID=0aa3a5f24d9596eb2d248edf36c3a952@[::1] UA='FPBX-14.0.1.19(13.17.2)'

I have to ask Mr. @tm1000 if i can have a key to sign modules, i dont want to make a unsigned module public.

@pietervos i will only test my scripts in the official SNG7 Distro.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.