Remote Voicemail – cannot leave message remote site

I have number of Asterisk boxes linked together using SIP; everything works ok except voicemail when calling a remote extension;

Example;
Site 1 calls site 2; site 2 doesn’t answer the phone so I want it to go to voicemail at site 2.

What happens is it tries to leave it at site 1.

I did some digging and one solution is to do a Cron job every five minutes to copy the voice mail to the remote Asterisk box.

Does any have any Ideas on this?

Extensions.conf

;SIP For Inter-Office Calls
exten => _[1-7]XX,1,Set(SIPTRUNK=${EXTEN:0:-2}"-SIP-TRUNK")
exten => _[1-7]XX,2,Dial(SIP/${SIPTRUNK}/${EXTEN},45)
exten => _[1-7]XX,3,VoiceMail(${EXTEN})
exten => _[1-7]XX,4,Playback(vm-goodbye)
exten => _[1-7]XX,5,Hangup()

sip.conf

[1-sip-trunk]
type=peer
context=internal
host=192.168.3.10
disallow=all
allow=g729
nat=no
canreinvite=yes
qualify=no

[2-sip-trunk]
type=peer
context=internal
host=192.168.0.10
disallow=all
allow=g729
canreinvite=yes
qualify=no

I found the problem it was quite simple in the end.

  1. I removed these two lines as the remote dialplain wil handel the voicemail.

exten => _[1-7]XX,3,VoiceMail(${EXTEN})
exten => _[1-7]XX,4,Playback(vm-goodbye)

;Remote dialplan
;Local Office Extensions
exten => _7XX,1,Dial(SIP/${EXTEN},45)
exten => _7XX,2,VoiceMail(${EXTEN})
exten => _7XX,3,Playback(vm-goodbye)
exten => _7XX,4,Hangup()

  1. The SIP trunk was giving up at the same time or just before the remote dial plan went two the second priority (both set for 45 seconds. I increased the SIP trunk to 60 seconds now it all works.

;SIP trunk
exten => _[1-7]XX,2,Dial(SIP/${SIPTRUNK}/${EXTEN},45)
;Remote dialplan
exten => _7XX,1,Dial(SIP/${EXTEN},45)

Hope this helps someone.