Recognizing and Modifying NOTIFY Message

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Recognizing and Modifying NOTIFY Message

Post by JRayfield »

1. Brekeke Product Name and Version:
3.9.4.3/517-1

2. Java version:
1.8.0_231

3. OS type and the version:
Windows Server 2016

4. UA (phone), gateway or other hardware/software involved:
3CX and Yealink Phones

5. Your problem:

I'm attempting to interface a 3CX IP PBX server and a Microsoft Exchange UM 2016 system, in order to use the voice-enabled auto attendant in the Exchange system.

In order to get this to work correctly, I need to 'recognize' a NOTIFY message that is sent from the 3CX server to the Exchange server and modify the "Subscription-State" line.

I looked at $request, but it doesn't appear to work with NOTIFY.

Is there any way to set up a Matching Pattern that would recognize a NOTIFY message where the Subscription-State line is "init;expires=60"? I need to modify that line to "terminated;reason=noresource".

Is this possible with BSS?

John
We have the interface working, except for one problem.

When the Exchange server sends a REFER back to 3CX server,
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Harold
Posts: 289
Joined: Sun Sep 21, 2008 10:31 pm
Location: Japan

Post by Harold »

> I looked at $request, but it doesn't appear to work with NOTIFY.

This is because that NOTIFY was sent within the same dialog what INVITE generated.

To catch NOTIFY, add the line below in the Deploy Pattern of current DialPlan rule which caches the INVITE.
&net.sip.outside.dialog.pattern = ^NOTIFY

If so, you can catch "NOTIFY" with $request=^NOTIFY by another rule.


If the above solution doesn't work... (because REFER is also sent within the INVITE's dialog), try &net.sip.outside.dialog.pattern=^REFER in the current rule and reject REFER by new rule.
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

I'm not sure that I understand.

Here's a Matching Pattern and Deploy pattern that I use in another BSS system, for an IP PBX to connect to another server. This is for inbound calls, routing them from the VoIP service provider's server to the IP PBX server. (Obviously, I've changed the IP addresses, registration 'user', etc).

Matching Pattern:

$request=^INVITE
$registered("1234567890")=true
$addr=123.456.789.012
To=sip:(9001)@

Deploy Pattern:

$auth=false
$rtp=false
$b2bua=false
To=sip:%1@987.654.321.098

Now, would I add "&net.sip.outside.dialog.pattern = ^NOTIFY", such as:

Deploy Pattern:

$auth=false
$rtp=false
$b2bua=false
To=sip:%1@987.654.321.098
&net.sip.outside.dialog.pattern = ^NOTIFY

Is this correct?

Then, I could have another Matching Pattern like this?:

$request=^NOTIFY
$registered("1234567890")=true
$addr=123.456.789.012

Is this correct?

Once I've matched the NOTIFY message, then I need to make sure that it's the correct NOTIFY message. So I also need to match the Subscription-State line in the NOTIFY message, by looking for "Subscription-State: init;expires=60" and change that to "Subscription-State: terminated;reason=noresource". How do I do that?

Then, once I know that I have the correct NOTIFY message, how do I change the "Subscription-State" line?

I've still got a LOT to learn about how to set up dial plans in BSS. So I REALLY appreciate any and all help to learn this.

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Harold
Posts: 289
Joined: Sun Sep 21, 2008 10:31 pm
Location: Japan

Post by Harold »

> Is this correct?

Yes if it is the rule for matching an INVITE which causes NOTIFY.

> So I also need to match the Subscription-State line in the NOTIFY message...

How about this?
[Matching Patterns]
$request=^NOTIFY
$registered("1234567890")=true
$addr=123.456.789.012
Subscription-State = init

[Deploy Patterns]
Subscription-State = terminated;reason=noresource


As I mentioned in my previous post, using NOTIFY rule may NOT meet the requirement if NOTIFY is sent for REFER. (because call transfer is triggered by REFER)
If so, catch the REFER by DialPlan and reject it.
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

How would the dialplan be written to reject the REFER?

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

If the NOTIFY was sent for REFER, would the CSeq section reference REFER? In this particular NOTIFY, CSeq only references NOTIFY.

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Harold
Posts: 289
Joined: Sun Sep 21, 2008 10:31 pm
Location: Japan

Post by Harold »

> How would the dialplan be written to reject the REFER?

Put the line below in the rule for INVITE.
&net.sip.outside.dialog.pattern = ^REFER

And add the rule like this for REFER. This rule rejects REFER with the "603 Decline".
[Matching Patterns]
$request = ^REFER

[Deploy Patterns]
$response = 603


> If the NOTIFY was sent for REFER, would the CSeq section reference REFER?

No.. This is because REFER is sent from UAS but NOTIFY is sent from UAC.

> In this particular NOTIFY, CSeq only references NOTIFY.

Right.
Why do you want to compare CSeq?
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

I don't think it would work to reject the REFER. The REFER needs to be passed through to the 3CX server to initiate the transfer.

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

is it ok to allow the transfer?
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

I think I misunderstood something.

When the REFER is sent to the 3CX server, it initiates the transfer. That is good.

3CX then responds with a NOTIFY in which the Subscription-State is "init;expires=60". And the sipfrag portions is "100 TRYING".

It's at this point that I need to be able to change this NOTIFY message (change the Subscription-State line to "terminated;reason=noresource" and the sipfrag portion "BYE") and send it on to the Exchange server. This should cause the Exchange server to send a BYE back that will be forwarded to the 3CX server.

The above is exactly what needs to happen (obviously various acknowledgments of the 'primary' messages aren't included in the above description).

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

Is there no BYE sent from the Exchange server currently?

Are you sure that "terminated" in Subscription-State line triggers BYE?

Do you want to close the original INVITE session just after the transfer happens?
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

Yes, when Exchange receives the NOTIFY with the "terminated" in it, Exchange then sends a BYE to close the incoming connection to the Exchange server from the PBX. This is how the current Mitel PBX system is working with Exchange. I want to mimic that operation with the 3CX/Exchange system.

Yes, the original INVITE needs to be closed after the REFER is sent and the transfer has happened.

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

so currently how do you close the original INVITE session? Do you need to send a BYE from 3CX?

Regards to the modifying NOTIFY, it might be possible to replace "Subscription-State" line to have the "terminated" but it is impossible to replace the sipfrag portion.

Does the Exchange send BYE even if the sipfrag portions is "100 TRYING"
within the NOTIFY with the "terminated" ?
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

Currently, when the transfer target (the extension to which the call will be transferred) answers, 3CX sends the NOTIFY with "terminate". When the Exchange server gets this, it sends a BYE back to 3CX to terminate that connection (the connection that has been up between 3CX and the Exchange server, during the time that the target extension has been ringing).

I don't know if the Exchange server will send a BYE if the sipfrag portion is "100 TRYING", or not. I would just have to try it. But I suspect that it won't work correctly.
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

Another idea is to write a plugin code to send BYE from SIP server to both UAC and UAS when NOTIFY request is received.
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

That would probably work. I don't know enough C, C# (yet) or Java to know how to write the plugin, but that is a good idea.

John
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
mitu
Posts: 10
Joined: Fri Feb 25, 2005 2:19 pm

Post by mitu »

I will send you the source code over TSC.
JRayfield
Posts: 147
Joined: Mon Dec 03, 2012 5:50 pm
Location: Springfield, MO

Post by JRayfield »

What is TSC?
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
mitu
Posts: 10
Joined: Fri Feb 25, 2005 2:19 pm

Post by mitu »

> What is TSC?

It is Technical Support Contract you already applied.
Post Reply