Getvar Of CHANNEL Not Working For A Couple Of Items

Home » Asterisk Users » Getvar Of CHANNEL Not Working For A Couple Of Items
Asterisk Users 5 Comments

The following AMI command works well for all of the information I want:

action: Getvar actionid: act1
channel: PJSIP/Twilio-NA-W-3-In-00000028
Variable: CHANNEL(pjsip,XXXX)

Where XXXX can be one of the many available items. However, when I create a call from A to B, all of the items return properly except: local_addr and remote_addr. More specifically, they return correctly for the A leg (that initiated the call), but are blank for the B leg. According to the asterisk.org docs:

* local_addr – On inbound calls, the full IP address and port number that the INVITE request was received on. On outbound calls, the full IP address and port number that the INVITE request was transmitted from.

* remote_addr – On inbound calls, the full IP address and port number that the INVITE request was received from. On outbound calls, the full IP address and port number that the INVITE request was transmitted to.

So they should be set for the B leg (outbound invite) as well but they are not; they are blank. Is this a bug or am I misunderstanding something?

Thanks

Brian

5 thoughts on - Getvar Of CHANNEL Not Working For A Couple Of Items

  • Building on my last message, I am trying to get CHANNEL data using getvar (through the AMI). And although I’m getting responses, some values returned seem illogical. For example, phone 111 calls phone 222 via the PBX. Here’s the data I get back

    Channel A: “1688509741.112” , name: “PJSIP/111-00000064” , is originator: Y , call-Id: “u.l6kcou25cax60@mydomain.com” , local_uri: “” , local_tag: “1734d973-c4da-4ae8-a37d-5f7065f1fe54” , local_addr: “172.31.253.4:5060” , remote_uri: “\\\”TestPhone x111\\\” ” , remote_tag: “yinue4v5ufa4” , remote_addr: “172.31.253.20:5060”

    Channel B: “1688509741.113” , name: “PJSIP/222-00000065” , is originator: N , call-Id: “1f104544-fc1a-4414-ba74-68c526e294de” , local_uri: “\\\”TestPhone\\\” ” , local_tag: “ac5eeb59-f559-4bb7-a3c2-170ca7f05f8b” , local_addr: “” , remote_uri: “” , remote_tag: “klwqxe1fvt5wk” , remote_addr: “”

    And here’s what seems strange:

    Channel A’s local_uri looks like Channel B’s uri

    Channel A’s remote_uri looks like channel A’s uri

    Channel B’s local_uri looks like channel A’s uri

    Channel B’s remote_uri looks like channel B;s uri

    Channel B’s local_addr is blank

    Channel B’s remote_addr is blank

    I double checked my code and I’m definitely asking for the right info. In regards to the reversed URI’s, am I reading them wrong? Should A’s local URI be how to reach A, and A’s remote URI be how to reach B ?

    The missing local and remote addresses for B is just strange (mentioned in previous email)

    Thanks

    Brian

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of TTT
    Sent: Tuesday, July 4, 2023 6:37 PM
    To: ‘Asterisk Users Mailing List – Non-Commercial Discussion’
    Subject: [asterisk-users] Getvar of CHANNEL not working for a couple of items

    The following AMI command works well for all of the information I want:

    action: Getvar actionid: act1
    channel: PJSIP/Twilio-NA-W-3-In-00000028
    Variable: CHANNEL(pjsip,XXXX)

    Where XXXX can be one of the many available items. However, when I create a call from A to B, all of the items return properly except: local_addr and remote_addr. More specifically, they return correctly for the A leg (that initiated the call), but are blank for the B leg. According to the asterisk.org docs:

    * local_addr – On inbound calls, the full IP address and port number that the INVITE request was received on. On outbound calls, the full IP address and port number that the INVITE request was transmitted from.

    * remote_addr – On inbound calls, the full IP address and port number that the INVITE request was received from. On outbound calls, the full IP address and port number that the INVITE request was transmitted to.

    So they should be set for the B leg (outbound invite) as well but they are not; they are blank. Is this a bug or am I misunderstanding something?

    Thanks

    Brian

  • These aren’t strange. They look alike because of callerid and target dialed information. They are still independent call legs.

    I don’t know why they’re blank.

  • Channel A: “1688509741.112” , name: “PJSIP/111-00000064” , is originator: Y , call-Id: “u.l6kcou25cax60@mydomain.com ” , local_uri: “ ;user=phone>” , local_tag: “1734d973-c4da-4ae8-a37d-5f7065f1fe54” , local_addr: “172.31.253.4:5060 <http://172.31.253.4:5060> ” , remote_uri: “\\\”TestPhone x111\\\” >” , remote_tag: “yinue4v5ufa4” , remote_addr: “172.31.253.20:5060 <http://172.31.253.20:5060> “

    Channel B: “1688509741.113” , name: “PJSIP/222-00000065” , is originator: N , call-Id: “1f104544-fc1a-4414-ba74-68c526e294de” , local_uri: “\\\”TestPhone\\\” >” , local_tag: “ac5eeb59-f559-4bb7-a3c2-170ca7f05f8b” , local_addr: “” , remote_uri: “ ;line=46922>” , remote_tag: “klwqxe1fvt5wk” , remote_addr: “”

    And here’s what seems strange:

    Channel A’s local_uri looks like Channel B’s uri

    Channel A’s remote_uri looks like channel A’s uri

    Channel B’s local_uri looks like channel A’s uri

    Channel B’s remote_uri looks like channel B;s uri

    These aren’t strange. They look alike because of callerid and target dialed information. They are still independent call legs.

    I’m having trouble understanding your explanation (googling just led me to generic callerid and target info). I thought a phone’s local_uri would be how to reach that phone (not the other party), and vice versa for the remote_uri. If the above URI info is correct then I must misunderstand their meaning. Could you provide more explanation on how to interpret them (why they seems reversed to me), or a link?

    I assumed the remote & local URI where equivalent to the to & from lines (respectively) in the invite…

  • They are the From and To header, but what remote_uri and local_uri refers to changes depending on the direction of the SIP dialog.

    Received call: From = remote_uri, To = local_uri Sent call: From = local_uri, To = remote_uri

    The contents of each depend on callerid information, settings, the Contact of the target when doing an outgoing call, what the remote endpoint chose for To URI on a received call.

  • I found a clue as to why the second leg is not returning a local or remote address:

    [2023-07-06 11:40:35] WARNING[253072]: pjsip/dialplan_functions.c:903 channel_read_pjsip: No transport information for channel PJSIP/222-0000007d

    [2023-07-06 11:40:35] WARNING[935126]: func_channel.c:527 func_channel_read: Unknown or unavailable item requested: ‘pjsip,local_addr’

    [2023-07-06 11:40:35] WARNING[40100]: pjsip/dialplan_functions.c:917 channel_read_pjsip: No transport information for channel PJSIP/222-0000007d

    [2023-07-06 11:40:35] WARNING[935126]: func_channel.c:527 func_channel_read: Unknown or unavailable item requested: ‘pjsip,remote_addr’

    Well…maybe not a root cause but certainly something of interest. This works with the first leg, but not the second leg of the call.

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] Channel A: “1688509741.112” , name: “PJSIP/111-00000064” , is originator: Y , call-Id: “u.l6kcou25cax60@mydomain.com ” , local_uri: “ ;user=phone>” , local_tag: “1734d973-c4da-4ae8-a37d-5f7065f1fe54” , local_addr: “172.31.253.4:5060 <http://172.31.253.4:5060> ” , remote_uri: “\\\”TestPhone x111\\\” >” , remote_tag: “yinue4v5ufa4” , remote_addr: “172.31.253.20:5060 <http://172.31.253.20:5060> “

    Channel B: “1688509741.113” , name: “PJSIP/222-00000065” , is originator: N , call-Id: “1f104544-fc1a-4414-ba74-68c526e294de” , local_uri: “\\\”TestPhone\\\” >” , local_tag: “ac5eeb59-f559-4bb7-a3c2-170ca7f05f8b” , local_addr: “” , remote_uri: “ ;line=46922>” , remote_tag: “klwqxe1fvt5wk” , remote_addr: “”

    And here’s what seems strange:

    Channel A’s local_uri looks like Channel B’s uri

    Channel A’s remote_uri looks like channel A’s uri

    Channel B’s local_uri looks like channel A’s uri

    Channel B’s remote_uri looks like channel B;s uri

    These aren’t strange. They look alike because of callerid and target dialed information. They are still independent call legs.

    I’m having trouble understanding your explanation (googling just led me to generic callerid and target info). I thought a phone’s local_uri would be how to reach that phone (not the other party), and vice versa for the remote_uri. If the above URI info is correct then I must misunderstand their meaning. Could you provide more explanation on how to interpret them (why they seems reversed to me), or a link?

    I assumed the remote & local URI where equivalent to the to & from lines (respectively) in the invite…

    They are the From and To header, but what remote_uri and local_uri refers to changes depending on the direction of the SIP dialog.

    Received call: From = remote_uri, To = local_uri

    Sent call: From = local_uri, To = remote_uri

    The contents of each depend on callerid information, settings, the Contact of the target when doing an outgoing call, what the remote endpoint chose for To URI on a received call.