Forward notify to UAC

Hi,

I’ve setup an asterisk server and successfully contected voip phones to asterisk. But phones requies to recieve and send some notify to other phones in call. Currently phones send notify to asterisk but asterisk does not forward that notify to other UAC. Is there a way to forward or recreate notification on-the-fly and send it to other UACs

Sample Notify

NOTIFY sip:{TO_NUMBER}@{ASTERISK_IP} SIP/2.0
Event:Some-event
Subscription-State:active
Content-Type:message/plain
To:"{TO_NUMBER}"sip:{TO_NUMBER}@{TO_IP};tag=8cb305c2-14cb-4580-8020-ae3d8d7a07c7
From:sip:{FROM_NUMBER}@{FROM_IP};tag=0922324631353641A9020000
Call-ID:fa9291b0-1c29-4d1e-828c-5c7a879d3711
Max-Forwards:70
CSeq:1 NOTIFY
Contact:sip:{FROM_NUMBER}@{FROM_IP}
Via:SIP/2.0/UDP {FROM_IP};branch=z9hG4bKAD7D05DF31370F123E1735D64F242D23;etype_1_eno_0
Content-Length:45

{SOME MESSAGE HEADER}

I’ve also tried to put kamailio in front and wrote a simple client with pjsip but when I make a call from the client I’ve wrote, a unique call-id is generated on the client side for invite method than asterisk create it’s own.
The flow looks like (1) Client → (2) Kamailio → (3) Asterisk → (4) Kamailio → (5) UAC.

So generated callid from client is same until 3rd step. But when asterisk send invite to uac it changes callid which can be seen in step 4. And when I forward notify directly from kamailio after invites has been accepted by clients, pjsip says 481 Call/Transaction Does Not Exist which makes sense since the client does not know the new call-id. Therefore putting kamailio in front to forward notifies did not work either

Thank you

Within Asterisk there is no such capability to forward NOTIFY requests.

Also, it is of the nature of the SIP protocol that requests such as NOTIFY can only be sent to a UAS. However, that is OK, because (5) is a UAS, not a UAC in your call flow. ((3) is a UAS on the left and a UAC on the right.)

Okay then, I have tried to send notify with pjsip send notify endpoint command which is triggered by the client and the notification type defined in pjsip_notify.conf. However other side of the call throws error saying 481 Call Leg/Transaction Does Not Exist. Isn’t notifies needs to be separate from the calls and if it is not how can I send a notify accepted by the VoIP phone. Here is the packets

  1. First Notify sended from asterisk

NOTIFY sip:{TO_NUMBER}@{TO_IP}:5060 SIP/2.0
Via: SIP/2.0/UDP 10.10.10.1:5060;rport;branch=z9hG4bKPj0d00d827-71f7-4c83-95cf-4192e1d68812
From: sip:{TO_NUMBER}@{ASTERISK_IP};tag=5e0bfdd0-1251-4620-8b10-3d461cbe9686
To: sip:{TO_NUMBER}@{TO_IP}
Contact: sip:66575@{ASTERISK_IP}:5060
Call-ID: b6fd0f6e-aad4-4277-b195-7317400012f7
CSeq: 48132 NOTIFY
Subscription-State: terminated
Event: SomeEvent
Max-Forwards: 70
User-Agent: Asterisk PBX 18.11.1
Content-Type: message/plain
Content-Length: 10

{Notify Body}

  1. Response from VOIP Phone

SIP/2.0 481 Call Leg/Transaction Does Not Exist
Call-ID:b6fd0f6e-aad4-4277-b195-7317400012f7
CSeq:48132 NOTIFY
From:sip:{TO_NUMBER}@{ASTERISK_IP};tag=5e0bfdd0-1251-4620-8b10-3d461cbe9686
To:sip:{TO_NUMBER}@{TO_IP};tag=4A59324631353641879A0100
Via:SIP/2.0/UDP {ASTERISK_IP}:5060;rport;branch=z9hG4bKPj0d00d827-71f7-4c83-95cf-4192e1d68812
Content-Length:0

By the way of course the phone sees Call-ID: b6fd0f6e-aad4-4277-b195-7317400012f7 first time with this notify, prior to the notify request phone never encountered with this id

The “pjsip send notify” CLI command sends an unsolicited out of dialog NOTIFY request. It does not support sending one within a call, if that’s required then it won’t work. There’s no support for doing this in Asterisk, adding support would require code changes.

try take a look at sending it via AMI as that one has an option for Channel
https://wiki.asterisk.org/wiki/display/AST/Asterisk+19+ManagerAction_PJSIPNotify
please note I have not testet where that will work or not

1 Like

@TheMark Ooh nice find! That should work. Added back in February of 2018.

It worked great finally my phone is happy with the coming notify. But how can I query channel-name with endpoint number because PJSIP/NUM apparently not a valid channel name but PJSIP/NUM-0000001 is valid

now that you are using AMI you can do a Status, that will return a list of all active channels

Action: Status

Response: Success
EventList: start
Message: Channel status will follow

Event: Status
Privilege: Call
Channel: SIP/hpbx-0000009b
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 209
CallerIDName: Uma Thurman
ConnectedLineNum: 203
ConnectedLineName: Chuck Norris
Language: da
AccountCode: 
Context: hpbx
Exten: 
Priority: 1
Uniqueid: 1650615524.155
Linkedid: 1650615523.154
Type: SIP
DNID: 
EffectiveConnectedLineNum: 203
EffectiveConnectedLineName: Chuck Norris
TimeToHangup: 0
BridgeID: b08be420-6453-4749-a6c5-0823ed6ea75a
Application: AppDial
Data: (Outgoing Line)
Nativeformats: (alaw)
Readformat: alaw
Readtrans: 
Writeformat: alaw
Writetrans: 
Callgroup: 0
Pickupgroup: 0
Seconds: 238

Event: Status
Privilege: Call
Channel: SIP/hpbx-0000009a
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 203
CallerIDName: Chuck Norris
ConnectedLineNum: 209
ConnectedLineName: Uma Thurman
Language: da
AccountCode: 
Context: dial
Exten: 209
Priority: 4
Uniqueid: 1650615523.154
Linkedid: 1650615523.154
Type: SIP
DNID: 209
EffectiveConnectedLineNum: 209
EffectiveConnectedLineName: Uma Thurman
TimeToHangup: 0
BridgeID: b08be420-6453-4749-a6c5-0823ed6ea75a
Application: Dial
Data: SIP/209@hpbx,90,TtU(Dial_Handler)b(DIAL_HOOK,209,1)
Nativeformats: (alaw)
Readformat: alaw
Readtrans: 
Writeformat: alaw
Writetrans: 
Callgroup: 0
Pickupgroup: 0
Seconds: 238

Event: StatusComplete
EventList: Complete
ListItems: 2
Items: 2

alternative listen for Newchannel events or some other event

Event: Newchannel
Privilege: call,all
Timestamp: 1650615982.803467
Channel: SIP/hpbx-0000009c
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 203
CallerIDName: 203
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: da
AccountCode: 
Context: hpbx
Exten: 209
Priority: 1
Uniqueid: 1650615982.156
Linkedid: 1650615982.156

Or you can create custom events, from you dialplan, or simply set a variable that will only be set for the channel for which you want to do this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.