Hi Juha,

sorry you have so many issues using this.

o Juha Heinanen on 12/22/2013 09:30 AM:
> i tried to use system dsm to dispatch several simultaneous calls using
> dlg.dialout(b_leg).  however the second call of dlg.dialout produced
> error message:
> 
> Dec 22 10:09:36 siika sems[26659]: [#7f52cd6f9700] [startSessionUAC, 
> AmSessionContainer.cpp:261] ERROR:  482 Loop Detected
> 
> is that because @local_tag is the same in both calls?
is it? then it would be a bug. can you get more debug log of this?

maybe you need to clear the ltag before calling dlg.dialout, otherwise
it may be reused (that feature is so that you can generate the ltag
before you already make the call).

> 
> is it even in theory possible to use the same system dsm to make many
> simultaneous outbound calls or do i need to go back to di_dialer, which
> can be invoked many times in parallel?
yes it is. I'm attaching you the dsm scripts I've used for testing
prepaid (though with master of some months ago).

it would be called from python like this:

def gen_call(timer, expected, domain, balance, initial_interval,
initial_rate, follow_interval, follow_rate, feature_code,
free_minutes_eligible=0, free_seconds=0):
  s.postDSMEvent('callgen', [['cmd','callout'], \
      ['caller','a'], ['callee','b'], ['domain',domain], \
      ['timer',str(timer)], ['expected',str(expected)],
      ['balance',str(balance)], ['initial_rate',str(initial_rate)],
      ['initial_interval',str(initial_interval)],
['follow_rate',str(follow_rate)],
      ['follow_interval',str(follow_interval)],
['feature_code',feature_code],
      ['free_seconds',str(free_seconds)],
      ['free_minutes_eligible', str(free_minutes_eligible)]  ])


hth
Stefan

-- pp_call_completing
import(mod_sys);
import(mod_monitoring);

initial state START
  enter { logVars(1); };

transition "call started" START - sessionStart / {
  sys.getTimestamp(start_ts);
  if test($timer!="") {
    setTimer(1, $timer);
  }
} -> RUNNING;

state RUNNING;

transition "got BYE" RUNNING - hangup / {
  sys.getTimestamp(stop_ts);
  sys.subTimestamp(stop_ts, start_ts);
  set(duration.sec=$stop_ts.tv_sec);
  set(duration.msec=$stop_ts.msec);
  set(duration.usec=$stop_ts.tv_usec);
  set(status="OK");
  set(cmd="feedback");

  postEvent($status_sink, 
duration.sec;duration.msec;duration.usec;status;id;cmd;caller;callee;reason;expected);
  stop(false);
} -> END;

transition "got timer" RUNNING - timer(#id==1) / {

  sys.getTimestamp(stop_ts);
  sys.subTimestamp(stop_ts, start_ts);
  set(duration.sec=$stop_ts.tv_sec);
  set(duration.msec=$stop_ts.msec);
  set(duration.usec=$stop_ts.tv_usec);
  set(status="OK");
  set(cmd="feedback");

  postEvent($status_sink, 
duration.sec;duration.msec;duration.usec;status;id;cmd;caller;callee;reason;expected);
  stop(true);
} -> END;

transition "call failed" START - failed / {
  set(status="failed");
  sets(reason="not established with #code #reason");
  sets(code=#code)
  set(cmd="feedback");
  postEvent($status_sink, code;status;id;cmd;caller;callee;reason;expected);
  stop(false);
} -> END;

state END;
-- 
--

import(mod_dlg);
import(mod_monitoring);
import(mod_py);

initial state ACCEPTING;

transition "startup" ACCEPTING - startup / {
   registerEventQueue("callgen");
   logAll(3);
} -> ACCEPTING;

transition "new call requested" ACCEPTING - event(#cmd==callout) / {
   logParams(1);

  -- caller (from) in 
  set(b_leg_caller=#caller);
  set(b_leg_auth_user=#caller);
  set(b_leg_auth_pwd=#pwd);
  -- callee
  set(b_leg_callee=#callee);

  -- caller and callee domain
  set(b_leg_domain=#domain);
  set(b_leg_app=pp_call_completing);

  sets($hdrs=P-free_seconds: #(free_seconds)\r\nP-free_minutes_eligible: 
#(free_minutes_eligible)\r\nP-feature_code: 
#(feature_code)\r\nP-initial_interval: #(initial_interval)\r\nP-initial_rate: 
#(initial_rate)\r\nP-follow_interval: #(follow_interval)\r\nP-follow_rate: 
#(follow_rate)\r\nP-Balance: #(balance)\r\n);
  set(b_leg_hdrs=$hdrs);

  
  -- set(b_leg_var.data=#data);
  set(b_leg_var.status_sink="callgen");
  set(b_leg_var.id="a_call");
  set(b_leg_var.caller=#caller);
  set(b_leg_var.callee=#callee);
  set(b_leg_var.timer=#timer);
  set(b_leg_var.expected=#expected);

  dlg.dialout(b_leg);

  log(2,$b_leg_ltag);
  clear($b_leg_ltag);
} -> ACCEPTING;

transition "status feedback" ACCEPTING - event(#cmd=="feedback") / {
  logParams(1);
  if test(#status=="OK") {
    set($duration_msec=#duration.msec);
    
    py(#
n = int(round(int(session.var('duration_msec'))/1000.0))
session.setvar('duration', str(n))
);
    log(1, $duration);
-- #duration.sec
    if test(#expected==$duration) {
      sets($c_status="ID #id #caller -> #callee expected #expected real 
#duration.sec usec #duration.usec (msec #duration.msec)");
      monitoring.addGlobal(ok, status,$c_status);
    } else {
      sets($c_status="time mismatch: ID #id #caller -> #callee expected 
#expected real #duration.sec usec #duration.usec (msec #duration.msec)");
      monitoring.addGlobal(failed, status,$c_status);
    }
  } 
  else {
    if test(#code==402) {
      if test($b_leg_var.expected==0) {
        sets($c_status="call rejected: ID #id #caller -> #callee expected 
#expected real - rejected with #code");
        monitoring.addGlobal(ok, status,$c_status);
      }
    else { 
      sets($c_status="not established: ID #id #caller -> #callee expected 
#expected real #duration.sec usec #duration.usec (msec #duration.msec)");
      monitoring.addGlobal(failed, status,$c_status);
    }
  }
  
} -> ACCEPTING;
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

Reply via email to