AMI Commands – not working as Expected, Maybe???

Home » Asterisk Users » AMI Commands – not working as Expected, Maybe???
Asterisk Users 1 Comment

Hi John,

I kind of facing the same problem that you were facing.
I am using similar configuration as you are for asterisk.
I am using java-asterisk library to communicate with asterisk.
In my code I am setting two variables (PIN, MREQID) and trying to access
them in dialplan (dialplan shown below).
When I send command to Asterisk to orginate, I get following result (result
shown below). I am wondering how should get access to individual variable
data. I was wondering if I should use Set(var,x,y) method to pull out the
part which is necessary for me. But wasnt sure if thats the right way.


One thought on - AMI Commands – not working as Expected, Maybe???

  • John,
    With the pointer that you gave me about sending Variables right at the end,
    I started tracing my socket communication with the asterisk.
    I found that the “variables” were not the last parameters (although I was
    adding them last). I had to tweak opensource asterisk-java library code to
    handle the Variables separately and ensure that they come last.
    I put that change, and the things have started working. Also plan to raise
    this issue with Asterisk-Java and send fix. Below is the changed function in
    asterisk-java (posting it here as well, although asterisk-java will be the
    most appropriate mailing list for it. varValue and varName related changes
    are done by us.)

    Thanks again,

    private void appendGetters(StringBuffer sb, Object action, Set
    getters =
    Object varValue = null ;
    Object varName = null;

    for (Map.Entry entry : getters.entrySet())
    final String name = entry.getKey();
    final Method getter = entry.getValue();
    final Object value;“Inside appendGetters …. ” + name ) ;
    if (membersToIgnore.contains(name))

    value = getter.invoke(action);
    catch (Exception ex)
    logger.error(“Unable to retrieve property ‘” + name + “‘ of
    ” + action.getClass(), ex);

    if (value == null || value instanceof Class)

    final String mappedName = mapToAsterisk(getter);“MWT Mapped Name is ” + mappedName) ;
    if (value instanceof Map)
    if(!name.equals(“variables”)) {
    appendMap(sb, mappedName, (Map) value);
    } else {” MWT Setting Var variables”) ;
    varName = mappedName ;
    varValue = value ;
    else if (value instanceof String)
    appendString(sb, mappedName, (String) value);
    appendString(sb, mappedName, value.toString());

    if(varValue != null && varName != null) {“MWT Appending map again”) ;

    appendMap(sb, (String)varName, (Map) varValue);