Summary:ASTERISK-02657: Asterisk Manager API (sockets)
Reporter:Donny Kavanagh (donnyk)Labels:
Date Opened:2004-10-22 22:02:10Date Closed:2004-10-27 12:51:35
Versions:Frequency of
Environment:Attachments:( 0) pridump.diff
Description:Doing some extensive work with the manager api i've so far noticed two commands have issues.

pri show span # (when called using Action: Command)
Action: Originate


First off i appoligze for the lack of detail, i run this asterisk box at work and our lanroom is down for the weekend for power testing so what i'm saying is from memory.  If further details are required i will be able to provide them monday.

#1 - When using 'Action: Command' over console, and calling 'Command: pri show span 1' the first two lines appear over sockets, however the last 3-5 lines appear on the console and do not come through the socket connection.  I was able to confirm this bug with two people on irc. One running 1.0.1 and another running a CVS from earlier in october both had the same problem.  When i run this command from console it prints the first two lines, then breaks for one line, then prints the rest so that may be the problem.  I actually intended to look at this while in the office, since it should be a very easy fix but i've been very busy.

#2 - When using Action: Originate to create a call, i pass all the lines one by one as required, and the call is created sucessfully, however when i pass 'SetVar: MYVARIABLE=DATA' the variable does not seem to make it to the context a 'NoOp(${MYVARIABLE})' will turn up empty.  However, i was able to use in the socket/manager api connection 'Account: DATA' and a 'NoOp(${ACCOUNT})' contained what i was trying to pass.  This one here i was only having problems with late this evening, i tried to get someone to confirm it in irc but no one is around, however i checked and double checked everything so i think i am correct.

If required i can provide php scripts to recreate both these problems upon my return to work monday.

Comments:By: Donny Kavanagh (donnyk) 2004-10-23 16:22:22

I should make a small correction, in #1, it should say when using Action: Command over the manager interface (aka sockets)

By: Brian West (bkw918) 2004-10-23 16:43:40

Second one isn't a bug you are just doing it wrong.

Variable: MYVAR
Value: myvalue


By: Donny Kavanagh (donnyk) 2004-10-23 16:46:16

Ok thanks, i followed the format of the .call file since their wasnt much documentation on what i was trying to accomplish.  I guess i should have consulted the source :)


edited on: 10-23-04 16:58

By: Anthony Minessale (anthm) 2004-10-23 17:34:51

here is a solution to issue #1 but i made it against head.

By: Donny Kavanagh (donnyk) 2004-10-23 18:49:49

Would you be able to look at back porting that to v1-0 CVS?

I can wait for 1.0.2 but i think whats in CVS head is a long ways off from being in a release version.  Which i need because i'm running production systems.


By: Donny Kavanagh (donnyk) 2004-10-23 20:24:36

Reminder sent to anthm

See my post on the ticket, would u be able to back port this to v1-0 cvs?

By: Anthony Minessale (anthm) 2004-10-25 09:07:36

Try it and see
most changes are made to libpri anyway
so the patch might work on 1.0 too
patch it from /usr/src

cd /usr/src
patch --dry-run -p0 -i /path/to/pridump.diff
asuming /usr/src contains both asterisk and libpri dirs
if you see no errors , try removing the --dry-run to really do it.

By: Donny Kavanagh (donnyk) 2004-10-25 10:03:42

Everything is good except for the first hunk #1 of chan_zap, and thats against 1.0.1 release version.

I would try to take a look to see whats changed, but i am busy today at work as i'm going to be on course all week, but if you could try and fix this one thing and sneak it into the v1-0 cvs before 1.0.2 that would be great.  When u need it tested again post here, i have this bug monitored.


edited on: 10-25-04 11:15

By: Donny Kavanagh (donnyk) 2004-10-25 14:00:06

bkw, unless i'm just gone totally nuts, i coudn't get,

Variable: NAME
Value: somevalue

working either, so i went digging through the manager.c,

I found this

-- code --
static char mandescr_originate[] =
"Description: Generates an outgoing call to a Extension/Context/Priority or\n"
"  Application/Data\n"
"Variables: (Names marked with * are required)\n"  
"       *Channel: Channel name to call\n"
"       Exten: Extension to use (requires 'Context' and 'Priority')\n"
"       Context: Context to use (requires 'Exten' and 'Priority')\n"
"       Priority: Priority to use (requires 'Exten' and 'Context')\n"
"       Application: Application to use\n"
"       Data: Data to use (requires 'Application')\n"
"       Timeout: How long to wait for call to be answered (in ms)\n"
"       CallerID: Caller ID to be set on the outgoing channel\n"
"       Variable: Channel variable to set (VAR1=value1|VAR2=value2)\n"
"       Account: Account code\n"
"       Async: Set to 'true' for fast origination\n";
-- end code --

Sure enough, Variable: varname=whatever works fine.  This is a slight oversight however as all the commands match the .call file syntax except for this one.  It should be SetVar: varname=whatever just like in the .call file.  Either way, i'm just happy it works.

I'll document my expirences on the wiki soon.

By: Anthony Minessale (anthm) 2004-10-25 17:24:08

The changes to chan_zap are minimal all the dirty work are in libpri
if it's approved it can back port with ease if you just look at the patch I'm sure you can get it if it's hunk 1 remove the entire function
zt_pri_message(char *s)
and add the new one

static void zt_pri_message(int fd,char *s)

By: Mark Spencer (markster) 2004-10-25 22:39:00

pri issue fixed in CVS

By: Russell Bryant (russell) 2004-10-27 12:51:35

james ported the pri fix to 1.0