[asterisk-users] Problem sending a DTMF remotely. Please need help!!!

Pablo Bernasconi bernasconi.pablo at gmail.com
Tue Oct 6 17:40:32 CDT 2009


Hello, how are you?

I need to be able to send a DTMF to an existing channel remotely. So I made
a php script to do such with the Manager command PlayDTMF. I need it for
example to start a transfer.

isb177*CLI> features show
Builtin Feature           Default Current
---------------           ------- -------
Pickup                    *8      *8
Blind Transfer            #       #8
Attended Transfer                 *2
One Touch Monitor                 *1
Disconnect Call           *       **
Park Call
One Touch MixMonitor

Dynamic Feature           Default Current
---------------           ------- -------
(none)

Call parking
------------
Parking extension   :      70
Parking context     :      parkedcalls
Parked call extensions:      71-78


My script is:

#!/usr/bin/php -q
<?php
error_reporting (E_ALL);
set_time_limit(60);
ob_implicit_flush(false);
$ip_asterisk = "127.0.0.1";
$user_asterisk = "admin";
$pass_asterisk = "forward";
$canal = "SIP/1000-0a292360"; //hardcodeado

$oSocket = fsockopen($ip_asterisk, 5038, $errnum, $errdesc) or
die("Connection to host failed");
    fputs($oSocket, "Action: login\r\n");
    fputs($oSocket, "Username: $user_asterisk\r\n");
    fputs($oSocket, "Secret: $pass_asterisk\r\n\r\n");
    fputs($oSocket, "Action: PlayDTMF\r\n");
    fputs($oSocket, "Channel: $canal\r\n");
    fputs($oSocket, "Digit: #\r\n\r\n");
    usleep(500000);
    fputs($oSocket, "Action: PlayDTMF\r\n");
    fputs($oSocket, "Channel: $canal\r\n");
    fputs($oSocket, "Digit: 8\r\n\r\n");
    usleep(500000);
    fputs($oSocket, "Action: Logoff\r\n\r\n");

   $loaded = "";
    while (!feof($oSocket)){
        $buffer = fgets($oSocket, 4096);
        $loaded .= $buffer;    }
    $vec = explode("\n", $loaded);
    $len = count($vec);
    print_r($vec);
?>


The script output is:

Array
(
    [0] => Asterisk Call Manager/1.1
    [1] => Response: Success
    [2] => Message: Authentication accepted
    [3] =>
    [4] => Response: Success
    [5] => Message: DTMF successfully queued
    [6] =>
    [7] => Response: Success
    [8] => Message: DTMF successfully queued
    [9] =>
    [10] => Response: Goodbye
    [11] => Message: Thanks for all the fish.
    [12] =>
    [13] =>
)


When I run the script I can hear the two digit (only the audio) but nothing
happens, the Transfer menu doesnt start. The Cli shows:


[Oct  2 11:14:46] DEBUG[30054]: manager.c:2776 process_message: Manager
received command 'login'
  == Manager 'admin' logged on from 127.0.0.1
[Oct  2 11:14:46] DEBUG[30054]: manager.c:2776 process_message: Manager
received command 'PlayDTMF'
[Oct  2 11:14:46] DEBUG[30054]: channel.c:2055 ast_waitfor_nandfds: Thread
-1216881776 Blocking 'SIP/1000-0a292360', already blocked by thread
-1217414256 in procedure ast_waitfor_nandfds
[Oct  2 11:14:47] DEBUG[29533]: channel.c:3341 ast_write: Deadlock avoided
for write to channel 'SIP/1000-0a292360'
[Oct  2 11:14:47] DEBUG[30054]: manager.c:2776 process_message: Manager
received command 'PlayDTMF'
[Oct  2 11:14:47] DEBUG[30054]: channel.c:2055 ast_waitfor_nandfds: Thread
-1216881776 Blocking 'SIP/1000-0a292360', already blocked by thread
-1217414256 in procedure ast_waitfor_nandfds
[Oct  2 11:14:47] DEBUG[29533]: channel.c:3341 ast_write: Deadlock avoided
for write to channel 'SIP/1000-0a292360'
[Oct  2 11:14:47] DEBUG[30054]: manager.c:2776 process_message: Manager
received command 'Logoff'
  == Manager 'admin' logged off from 127.0.0.1



BUT, if I press #8 in the softphone, I can hear the two digit and
inmediately the Transfer menu begins playing 'pbx-transfer.gsm'. And the Cli
output in this case is:


[Oct  2 11:09:17] DEBUG[29533]: rtp.c:1148 ast_rtcp_read: Got RTCP report of
60 bytes
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:806 send_dtmf: Sending dtmf: 35 (#),
at 192.168.0.148
[Oct  2 11:09:20] DTMF[29533]: channel.c:2840 __ast_read: DTMF begin '#'
received on SIP/1000-0a292360
[Oct  2 11:09:20] DTMF[29533]: channel.c:2850 __ast_read: DTMF begin
passthrough '#' on SIP/1000-0a292360
[Oct  2 11:09:20] DEBUG[29533]: channel.c:4806 ast_generic_bridge: Got DTMF
begin on channel (SIP/1000-0a292360)
[Oct  2 11:09:20] DEBUG[29533]: channel.c:5150 ast_channel_bridge: Bridge
stops bridging channels SIP/1000-0a292360 and SIP/1001-0a026408
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:806 send_dtmf: Sending dtmf: 35 (#),
at 192.168.0.148
[Oct  2 11:09:20] DTMF[29533]: channel.c:2768 __ast_read: DTMF end '#'
received on SIP/1000-0a292360, duration 80 ms
[Oct  2 11:09:20] DTMF[29533]: channel.c:2808 __ast_read: DTMF end accepted
with begin '#' on SIP/1000-0a292360
[Oct  2 11:09:20] DTMF[29533]: channel.c:2824 __ast_read: DTMF end
passthrough '#' on SIP/1000-0a292360
[Oct  2 11:09:20] DEBUG[29533]: channel.c:4806 ast_generic_bridge: Got DTMF
end on channel (SIP/1000-0a292360)
[Oct  2 11:09:20] DEBUG[29533]: channel.c:5150 ast_channel_bridge: Bridge
stops bridging channels SIP/1000-0a292360 and SIP/1001-0a026408
[Oct  2 11:09:20] DEBUG[29533]: features.c:1836 ast_feature_interpret:
Feature interpret: chan=SIP/1000-0a292360, peer=SIP/1001-0a026408, code=#,
sense=1, features=2, dynamic=#
[Oct  2 11:09:20] DEBUG[29533]: features.c:2496 ast_bridge_call: Set time
limit to 2000
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:20] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
0000000b (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:806 send_dtmf: Sending dtmf: 56 (8),
at 192.168.0.148
[Oct  2 11:09:21] DTMF[29533]: channel.c:2840 __ast_read: DTMF begin '8'
received on SIP/1000-0a292360
[Oct  2 11:09:21] DTMF[29533]: channel.c:2850 __ast_read: DTMF begin
passthrough '8' on SIP/1000-0a292360
[Oct  2 11:09:21] DEBUG[29533]: channel.c:4806 ast_generic_bridge: Got DTMF
begin on channel (SIP/1000-0a292360)
[Oct  2 11:09:21] DEBUG[29533]: channel.c:5150 ast_channel_bridge: Bridge
stops bridging channels SIP/1000-0a292360 and SIP/1001-0a026408
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:806 send_dtmf: Sending dtmf: 56 (8),
at 192.168.0.148
[Oct  2 11:09:21] DTMF[29533]: channel.c:2768 __ast_read: DTMF end '8'
received on SIP/1000-0a292360, duration 120 ms
[Oct  2 11:09:21] DTMF[29533]: channel.c:2808 __ast_read: DTMF end accepted
with begin '8' on SIP/1000-0a292360
[Oct  2 11:09:21] DTMF[29533]: channel.c:2824 __ast_read: DTMF end
passthrough '8' on SIP/1000-0a292360
[Oct  2 11:09:21] DEBUG[29533]: channel.c:4806 ast_generic_bridge: Got DTMF
end on channel (SIP/1000-0a292360)
[Oct  2 11:09:21] DEBUG[29533]: channel.c:5150 ast_channel_bridge: Bridge
stops bridging channels SIP/1000-0a292360 and SIP/1001-0a026408
[Oct  2 11:09:21] DEBUG[29533]: features.c:1836 ast_feature_interpret:
Feature interpret: chan=SIP/1000-0a292360, peer=SIP/1001-0a026408, code=#8,
sense=1, features=2, dynamic=#
[Oct  2 11:09:21] DEBUG[29533]: features.c:1732 feature_interpret_helper:
Feature detected: fname=Blind Transfer sname=blindxfer exten=#8
    -- Music class default requested but no musiconhold loaded.
[Oct  2 11:09:21] DEBUG[29533]: channel.c:3616 set_format: Set channel
SIP/1000-0a292360 to write format gsm
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:3099 ast_rtp_raw_write: Difference is
1952, ms is 264
[Oct  2 11:09:21] DEBUG[29533]: channel.c:2362 ast_settimeout: Scheduling
timer at 160 sample intervals
    -- <SIP/1000-0a292360> Playing 'pbx-transfer.gsm' (language 'en')
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[29533]: rtp.c:958 process_rfc2833: - RTP 2833 Event:
00000008 (len = 4)
[Oct  2 11:09:21] DEBUG[16129]: rtp.c:1148 ast_rtcp_read: Got RTCP report of
60 bytes
[Oct  2 11:09:22] DEBUG[29533]: channel.c:2362 ast_settimeout: Scheduling
timer at 0 sample intervals
[Oct  2 11:09:22] DEBUG[29533]: channel.c:2362 ast_settimeout: Scheduling
timer at 0 sample intervals
[Oct  2 11:09:22] DEBUG[29533]: channel.c:3616 set_format: Set channel
SIP/1000-0a292360 to write format ulaw
[Oct  2 11:09:22] DEBUG[29533]: channel.c:3616 set_format: Set channel
SIP/1000-0a292360 to write format slin
[Oct  2 11:09:22] DEBUG[29533]: channel.c:2362 ast_settimeout: Scheduling
timer at 160 sample intervals
[Oct  2 11:09:22] DEBUG[29533]: channel.c:3017 ast_internal_timing_enabled:
Internal timing is disabled (option_internal_timing=0 chan->timingfd=32)
[Oct  2 11:09:22] DEBUG[29533]: channel.c:2474 ast_read_generator_actions:
Generator got voice, switching to phase locked mode
[Oct  2 11:09:22] DEBUG[29533]: channel.c:2362 ast_settimeout: Scheduling
timer at 0 sample intervals


My manager.conf is:

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
webenabled = yes
httptimeout = 3600
[admin]
secret = forward
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.254.0
permit=192.168.0.0/255.255.0.0
read =
system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan,all
write = system,call,agent,user,config,command,reporting,originate,all


My Asterisk version is 1.6.0.15, but I`ve tried it in 1.6.0.6 and 1.6.1.6
version and the same happens.
I dont know what I am missing...
Please help me.

Thank you very much.
Pablo Bernasconi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091006/48cbfccf/attachment.htm 


More information about the asterisk-users mailing list