marcelog / Nami

Asterisk manager interface (ami) client for nodejs
http://marcelog.github.com/Nami
Apache License 2.0
99 stars 59 forks source link

Originate Action isn't formatted correctly? #24

Closed nicobcn closed 10 years ago

nicobcn commented 10 years ago

Hi, I've realized that when sending an originate action with Nami in async mode (async:true), asterisk doesn't recognize the ActionID correctly, so it's impossible to trace the subsequent related events (like OriginateResponse Event)

The call itself proceeds, but with actionid recognized as "1".

Example captured with tcpdump from an Asterisk 1.8.7.0:

what nami.js sends:

id: 1 ActionID: 1 Action: Originate actionid: 1982 channel: Local/xxxxxx@from-internal context: from-internal callerid: xxxxxx exten: xxxxxx async: true priority: 1 timeout: 180000

what asterisk responds (when the 1st leg of the call has been established):

Event: OriginateResponse Privilege: call,all ActionID: 1 Response: Success Channel: Local/xxxxxx@from-internal-8789;1 Context: from-internal Exten: xxxxxx Reason: 4 Uniqueid: 1402076400.50940 CallerIDNum: xxxxxx CallerIDName: xxxxxx

I don't know why Nami sends the first two lines ("id:1" and "ActionID: 1") but it clearly has an effect on asterisk's interpretation of the ActionID.

Has anyone encountered this issue?

Thank you

marcelog commented 10 years ago

Hello!

ActionID is sent on purpose, so you can effectively trace the call. We could skip sending id, but in any case, it doesn't affect anything. ActionID is chosen by incrementing a counter, but you can set your own id after instantiating the action object, by overriding the action:

originate.ActionID = 'whatever';

Asterisk will honor the value you put there. It's actually intended to be used this way. You either stick to the selected actionid value or put your own, and then recover it later. It's working pretty well for me since a long time :)

Since this is not an issue, I'll close it.

nicobcn commented 10 years ago

OK, then I assume I'm doing something else wrongly because I set the action id like you suggested: originate.ActionID = '1982'; (as you can see, Nami sends "actionid: 1982" in the capture)

but asterisk's response contains "ActionID: 1", instead of "1982", so it's ignoring the value I set.

marcelog commented 10 years ago

you're setting the wrong property:

ActionID: 1
Action: Originate
actionid: 1982

it's not actionid, but ActionID

nicobcn commented 10 years ago

You're right marcelog. It's fixed now, thank you!.