[Freeswitch-users] Message Playback Stops

Michael De Lorenzo delorenzodesign at gmail.com
Tue Feb 22 10:22:31 MSK 2011


Hello,

I have a Freeswitch installation that is intended to make many calls
(thousands) and playback a single wav file.  The calls are successfully
processed (the recipient's phone rings), but the call almost immediately
disconnects, after about 1s.  Everything seems to work fine if I'm only
pushing one or two calls through the Freeswitch instance, but as soon as I
turn up the call rate (I'm still only doing about 50 concurrent sessions)
the playback begins to fail.

I've watched the calls go out from the console and nothing looks out of the
ordinary, except that the calls are disconnected with NORMAL CLEARING prior
to completion.

Here's the Lua script I'm using...

profile_id = argv[1];
account_code = argv[2];
client_id = argv[3];
caller_id_name = argv[4];
caller_id = argv[5];
dial_id = argv[6];
number_to_call = argv[7];
message_to_play = argv[8];
max_retries = argv[9];
retry_interval = argv[10];

local human_detected = false
local voicemail_detected = false;
local message_played = false;

recordings_directory = "/usr/local/freeswitch/recordings/messages/";

function setDialVariables(set_as_session_variables)
    local s = "profile_id=" .. profile_id;
    s = s .. ",account_code=" .. account_code;
    s = s .. ",client_id=" .. client_id;
    s = s .. ",caller_id_name=" .. caller_id_name;
    s = s .. ",caller_id=" .. caller_id;
    s = s .. ",dial_id=" .. dial_id;
    s = s .. ",number_to_call=" .. number_to_call;
    s = s .. ",message_to_play=" .. message_to_play;

    freeswitch.consoleLog("notice", s .. "\n");

    return s
end

function printSessionVariables()
    freeswitch.consoleLog("notice", "******* PRINTING SESSION VARIABLES
**********\n");
    -- ommitted
    freeswitch.consoleLog("notice",
"**********************************************\n");
end

function onInput(s, type, obj, arg)
    if(type == "event" and voicemail_detected == false) then
        freeswitch.consoleLog("debug","************ VOICE MAIL/ANSWERING
MACHINE DETECTED *************\n");
        voicemail_detected = true;
        return "break";
    end
    return true;
end

function playbackMessage(sleepTime)
    message_played = false;
    session:sleep(sleepTime);
    -- play a file
    message_file = recordings_directory .. message_to_play;
    freeswitch.consoleLog("notice", "Playing file: " .. message_file ..
"\n");
    session:streamFile(message_file);
    freeswitch.consoleLog("notice", "!!!!! Finished playing the file
!!!!!\n");
    message_played = true;
end

session = freeswitch.Session("{" .. setDialVariables(false) ..
",ignore_early_media=true,origination_caller_id_name=" .. caller_id_name ..
",origination_caller_id_number=+1" .. caller_id .. "}sofia/gateway/gateway_"
.. profile_id .. "/" .. number_to_call);

while(session:ready()) do
   setDialVariables(true)
   session:answer();

   -- session:execute("continue_on_fail","true");
   session:setInputCallback("onInput","true");
   session:execute("avmd","start");

   playbackMessage(200);

   vm_status = voicemail_detected == true and "yes" or "no"
   freeswitch.consoleLog("info", "Was VM detected? " .. vm_status .. "\n");
   if(voicemail_detected) then
      return "break";
   end

   freeswitch.consoleLog("notice", "Played the message at least once and
checked for VM, we should be exiting the loop.\n")
end

if (voicemail_detected) then
    freeswitch.consoleLog("info", "Playback for voicemail.\n");
    session:execute("avmd","stop");
    playbackMessage(5000);
end

freeswitch.consoleLog("info", "All finished, hanging up the session.\n");
session:hangup();

Any help would be greatly appreciated.

Thank you,

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110222/ff377f8b/attachment.html 


More information about the FreeSWITCH-users mailing list