I also had the problem that pjsip wouldn't re-register after the WAN connection was down for a while. In some cases it might help to add auth_rejection_permanent = false
to your registration section, but as far as I understand, at least after retry_interval * max_retries
asterisk won't try to re-register until it's reloaded.
I use a helper script that periodically checks for a desired registration. If asterisk isn't registered after 5 minutes while the box is online, asterisk gets restarted. I'm not perfectly happy with this script, as it relies on ping, but it works well for me so far. If your box is also your DSL modem there might be better solutions.
/usr/bin/asterisk_check_registration.sh
#/bin/sh
# Check asterisk registration every 5 minutes.
# When not registered, check internet connection.
# Restart asterisk after 5 minutes, when not
# registered although internet connection works.
registration=reg_arcor
ping_host=arcor.de # must respond to ping
reg_failed_counter=0
while : ; do
if ( asterisk -rx "pjsip show registration $registration" | grep -qw "Registered" ); then
reg_failed_counter=0
sleep 5m
else
if ( ping -c 1 $ping_host > /dev/null ); then # are we online?
let "reg_failed_counter++"
if [ "$reg_failed_counter" -ge "5" ]; then
/etc/init.d/asterisk restart
reg_failed_counter=0 # gives asterisk at least 5 minutes to restart and register
fi
fi
sleep 1m
fi
done
If you add this script to rc.local, make it run in the background, so that exit 0
can be reached. Otherwise you would have to kill the script manually every time you wantedt to reboot
/usr/bin/asterisk_check_registration.sh &
exit 0