Hello everyone, I hope someone can help me with this problem.
I am trying to generate an automated confirmation sistem for a booking system for a community group. The problem I am having is that the sistem will dial internal extensions without any problems, but as soon as I try to dial external number via a trunk it totally fails, as sinapsis of the web code (php) ;
$texto = 'Bienvenido al sistema de ingreso.';
$numero = '945071785';
$text = '188';
$trunk = 'GTD0';
$numero = $numero.'@'.$trunk;
$socket = fsockopen("10.128.12.16", 5038, $errno, $errstr, 30);
if (!$socket) {
echo "ERROR: $errstr ($errno)\n";
} else {
// Asterisk server login
fputs($socket, "Action: Login\r\nUsername: username\r\nSecret: secret\r\nEvents: off\r\n\r\n");
fputs($socket, "Action: Originate\r\nChannel: SIP/$numero\r\nContext: automarcado\r\nExten: s\r\nPriority: 1\r\nVariable: texto=$text\r\nAsync: yes\r\n\r\n");
// Log off from the Asterisk server
fputs($socket, "Action: Logoff\r\n\r\n");
while (!feof($socket)) {
$wrets = fgets($socket, 8192);
echo $wrets;
}
fclose($socket);
}
//End of code
My extensions.conf :
[automarcado]
exten => s,1,NoOp(Starting outgoing call)
same => n,Set(agi_arg_1=${texto})
same => n,AGI(automarcado.php)
same => n,Hangup()
And my trunk info is as follows:
type=peer
*context=outgoing
host=10.32.0.0
fromusername=username
fromdomain=10.16.0.0
bindport=5060
disallow=all
allow=alaw&ulaw
canreinvite=no
nat=yes
dtmfmode=rfc2833
qualify=yes
allowguest=yes
And the debug shows the following:
Asterisk 11.25.3 currently running on issabel (pid = 2423)
-- Remote UNIX connection
-- Remote UNIX connection disconnected
-- Remote UNIX connection
-- Remote UNIX connection disconnected
== Manager 'gas' logged on from 10.128.2.16
== Manager 'gas' logged off from 10.128.2.16
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Audio is at 11352
Adding codec 100004 (alaw) to SDP
Adding codec 100003 (ulaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 10.32.0.0:5060:
INVITE sip:945071785@10.32.0.0 SIP/2.0
Via: SIP/2.0/UDP 10.16.0.0:5060;branch=z9hG4bK1db68007;rport
Max-Forwards: 70
From: "Anonymous" <sip:anonymous@10.16.0.0>;tag=as4f8b6ca9
To: <sip:945071785@10.32.0.0>
Contact: <sip:anonymous@10.16.0.0:5060>
Call-ID: 0e83de767a5254303757198b5b8f12e1@10.16.0.0
CSeq: 102 INVITE
User-Agent: IPBX-2.11.0(11.25.3)
Date: Mon, 10 Jun 2024 21:32:02 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 254
v=0
o=root 626542478 626542478 IN IP4 10.16.0.0
s=Asterisk PBX 11.25.3
c=IN IP4 10.16.0.0
t=0 0
m=audio 11352 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
<--- SIP read from UDP:10.32.0.0:5060 --->
SIP/2.0 100 Trying
Call-ID: 0e83de767a5254303757198b5b8f12e1@10.16.0.0
CSeq: 102 INVITE
From: "Anonymous" <sip:anonymous@10.16.0.0>;tag=as4f8b6ca9
To: <sip:945071785@10.32.0.0>;tag=sip+1+230400f5+9be95805
Via: SIP/2.0/UDP 10.16.0.0:5060;received=10.16.0.0;rport=5060;branch=z9hG4bK1db68007
Server: SIP/2.0
Content-Length: 0
<------------->
--- (8 headers 0 lines) ---
<--- SIP read from UDP:10.32.0.0:5060 --->
OPTIONS sip:10.16.0.0:5060 SIP/2.0
Via: SIP/2.0/UDP 10.32.0.0:5060;branch=z9hG4bK+2b0771b38d14f18cb5745fc8baa10c181+sip+1+f0d8449d
Max-Forwards: 70
Call-ID: AEABC918-1@10.32.0.0:5060
From: <sip:10.32.0.0:5060;transport=udp;lr>;tag=sip+1+1e170107+582f4661
CSeq: 490161719 OPTIONS
Content-Length: 0
To: sip:10.16.0.0:5060
Contact: <sip:10.32.0.0:5060;transport=udp;lr>
Accept: application/sdp, application/dtmf-relay
<------------->
--- (10 headers 0 lines) ---
Sending to 10.32.0.0:5060 (NAT)
Looking for s in from-sip-external (domain 10.16.0.0)
<--- Transmitting (NAT) to 10.32.0.0:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.32.0.0:5060;branch=z9hG4bK+2b0771b38d14f18cb5745fc8baa10c181+sip+1+f0d8449d;received=10.32.0.0;rport=5060
From: <sip:10.32.0.0:5060;transport=udp;lr>;tag=sip+1+1e170107+582f4661
To: sip:10.16.0.0:5060;tag=as37b558e5
Call-ID: AEABC918-1@10.32.0.0:5060
CSeq: 490161719 OPTIONS
Server: IPBX-2.11.0(11.25.3)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:10.16.0.0:5060>
Accept: application/sdp
Content-Length: 0
<------------>
Scheduling destruction of SIP dialog 'AEABC918-1@10.32.0.0:5060' in 32000 ms (Method: OPTIONS)
Really destroying SIP dialog 'A1327577-1@10.32.0.0:5060' Method: OPTIONS
This is all the info I think that can help, as I said, the code allows me realice the call to an extensión but not to an external number via the trunk. I have been stuck on this problema for a couple of weeks now so any help would be greatly appreciated.
Just in case I am from Chile, so time differance may effect my answers to any questions.
Thanks for your help.
Chris