Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
3CX and Brekeke SIP Server (BSS)
Author Message
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Sat Oct 28, 2023 9:33 am    Post subject: 3CX and Brekeke SIP Server (BSS) Reply with quote

1. Brekeke Product Name and Version:
Brekeke SIP Server - 3.14.5.17/563.2

2. Java version:
11.0.15

3. OS type and the version:
Windows Server 2012

4. UA (phone), gateway or other hardware/software involved:
3CX IP PBX

5. Your problem:
3CX makes use of the rinstance parameter in the Contact field field when registering with a SIP server. I see that BSS is handling that, as I see the rinstance parameter being returned back to the 3CX server in the 200 OK message after sucessful registeration.

3CX also tries to use the rinstance parameter on inbound calls. My upstream service provider is IP authenticated, so they don't give me the rinstance parameter.

For inbound calls coming from my upstream provider, through BSS, to the 3CX server, is there a way to add the rinstance parameter with the correct value to inbound calls, to forward to the 3CX server?

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Sun Oct 29, 2023 5:59 pm    Post subject: Reply with quote

How do you forward an incoming call from the upstream provider to the 3CX through the Brekeke SIP Server?

Does the caller at the upstream provider dial the 3CX's registered number at the Brekeke?
Or do you use any DialPlan rules for forwarding an incoming call to the 3CX?
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Mon Oct 30, 2023 6:09 am    Post subject: Reply with quote

Yes, I'm using DialPlan rules. All DID numbers are entered into BSS, using Aliases.

John

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Mon Oct 30, 2023 11:02 am    Post subject: Reply with quote

$regdb.URIparam("<UserName>") returns the registered URI parameters.
So to get the rinsance's value,
use $param($regdb.URIparam("<UserName>"),"rinsance")

The example below puts rinsance's value in the INVITE's To-header if the registered username is "9999".

Matching Patterns
$request = ^INVITE
$param($regdb.URIparam("9999"),"rinsance") = (.+)
Deploy Patterns
To/uri/param/rinstance = %1
$target = %{$regaddr("9999")}
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Tue Oct 31, 2023 10:29 am    Post subject: Reply with quote

Here are my DialPlans.

When a call comes in, it looks it up in the Alias list/database.

It if finds it there, then it does a 302 Move (forwards the call) to my STIR/SHAKEN service.

The call then comes back and forwards the call on to the proper 3CX system.

I've replaced the IP addresses of my upstream provider with 'x' to hide 'identities'. The IP address of my STIR/SHAKEN service is replaced with 'y'.

What I need to be able to do is to do what you're example shows, but I need to be able to do this with each registered UserName (I have many registered users on this system). I don't know of my STIR/SHAKEN service can handle the rinstance parameter, so it might be best to 'insert' it into the INVITE just before it's sent to the 3CX servers.

First Matching Plan:
===========================================
$request = ^INVITE
$addr = ^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$
To = sip:(.+)@
$alias.lookup("%1") = (.+)/(.+)
$regAddr("%2") = (.+)
===========================================
First Deploy Plan:
===========================================
&inbound.to = sip:%1@%4
$rtp = %3
$auth = false
$continue = true
===========================================

Second Matching Plan:
===========================================
$request = ^INVITE
&inbound.to = (.+)
Identity = .+
To = sip:(.+)@
===========================================
Second Deploy Plan:
===========================================
$b2bua = true
To = sip:%2@yyy.yyy.yyy.yyy
$session = failover %1
&failover.timer.provisional = 120
&failover.redirection = false
===========================================

Third Matching Plan:
===========================================
$request = ^INVITE
&inbound.to = (.+)
===========================================
Third Deploy Plan:
===========================================
$b2bua = true
To = %1
===========================================

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Tue Oct 31, 2023 9:19 pm    Post subject: Reply with quote

Does the STIR/SHAKEN service return "302 Move"?
Does this "302 Move" carry the call destination URI in Contact header?
Can you paste the "302 Move" packet here?
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Wed Nov 01, 2023 7:04 am    Post subject: Reply with quote

Yes, a 302 Moved Temporarily is returned.

Here's a SIP Message. I've removed the actual IP addresses.
The 'aaa.aaa.aaa.aaa' is the correct IP address of the 3CX server to which the call is being sent.

SIP/2.0 302 Moved Temporarily
Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bKff331d26af050-270bc515-2fe321
To: <sip:14171234567@yyy.yyy.yyy.yyy>
From: "JOHN RAYFIELD" <sip:1417zzzzzzz;verstat=TN-Validation-Passed@xxx.xxx.xxx.xxx>;tag=b8f1e7adfs
Contact: <sip:14171234567@aaa.aaa.aaa.aaa>
Call-ID: f1b3e7a3-41c54ac7-c054ca3d-bd4677c2
CSeq: 1 INVITE
Reason: SIP;cause=302;text="no-fraud-detected"
Content-Length: 0

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Wed Nov 01, 2023 10:30 am    Post subject: Reply with quote

The first rule will be like this for inserting "rinsance".

Matching Patterns
$request = ^INVITE
$addr = ^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$|^xxx.xxx.xxx.xxx$
To = sip:(.+)@
$alias.lookup("%1") = (.+)/(.+)
$regAddr("%2") = (.+)
$param($regdb.URIparam("%2"),"rinsance") = (.+)
Deploy Patterns
&inbound.to = sip:%1@%4
$rtp = %3
$auth = false
To/uri/param/rinstance = %5
$continue = true
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Wed Nov 01, 2023 12:38 pm    Post subject: Reply with quote

That did not work.

Incoming calls were not forwarded to the STIR/SHAKEN service (yyy.yyy.yyy.yyy in my 2nd Deploy Pattern).

It appears that after this new 1st Dialplan, the Matching Pattern of the 2nd Dial Plan isn't being matched (if I'm understanding the DialPlan correctly).

John

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Wed Nov 01, 2023 2:26 pm    Post subject: Reply with quote

Let you enable the DialPlan log to see why the second rule was not matched.
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Wed Nov 01, 2023 2:44 pm    Post subject: Reply with quote

How do I enable Dial Plan logs?
_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Wed Nov 01, 2023 6:53 pm    Post subject: Reply with quote

It is [Diagnostics]->[Debug Logs] page -> "Dial Plan" category.
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Thu Nov 02, 2023 7:12 am    Post subject: Reply with quote

I found this in the logs:

Pattern: $param($regdb.URIparam("%2"),"rinsance") = (.+)
Input: $param($regdb.URIparam("rayfield001"),"rinsance") = null
Result: false

And this showed the typo that was causing the problem.

I corrected this typo and now the rinstance parameter is showing up in the To field:

However, that's not what I need. Here's what 3CX states:

"3CX tries first to find an “rinstance” parameter in the RURI SIP field in an INVITE to match against a SIP Trunk, only present in Register-based providers. If this exists, then 3CX checks if this “rinstance” value was used to register one of the configured SIP Trunks and if found, match it with that specific Trunk"

So, I need the rinstance parameter in the INVITE message that is sent to 3CX for an inbound call.

Here's an example from 3CX's website:

Request-Line: INVITE sip:DID@2.2.2.2:5060;rinstance=187128bdfcec4b74 SIP/2.0

So what would be the correct format of the line in the Deploy Patttern to add the rinstance to the INVITE?

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Thu Nov 02, 2023 11:14 am    Post subject: Reply with quote

Replace the Request URI with $request in Deploy Patterns.

https://docs.brekeke.com/sip/request-2
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Thu Nov 02, 2023 3:26 pm    Post subject: Reply with quote

So here's what you gave me for the Deploy Pattern:

&inbound.to = sip:%1@%4
$rtp = %3
$auth = false
To/uri/param/rinstance = %5
$continue = true

I replaced the "To/uri/param/rinstance - %5" line with:

$request = INVITE sip:%1@%4;rinstance=%5

This appeared to work, except that the resulting INVITE sent to the 3CX server had two "sip:did-number@3CX-server-ipaddress;rinstance=bunch-of-characters"

So I'm getting a duplicate of the parameters in the INVITE. Why?

John
John

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net


Last edited by JRayfield on Thu Nov 02, 2023 4:56 pm; edited 1 time in total
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Thu Nov 02, 2023 4:56 pm    Post subject: Reply with quote

The definition will be like this.
$request= INVITE sip:%1@%4;rinstance=%5 SIP/2.0

You may need to insert $request= in the Deploy Patterns of Second and Third rules. so store the rinstance's value in a variable like what you did as &inbound.to.
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Thu Nov 02, 2023 5:30 pm    Post subject: Reply with quote

Thank you Laurie.

I was pretty close with my last try. I forgot the "SIP/2.0".

I was going to ask you about using a variable to store the rinstance value - something like this in the 1st Deploy Pattern:

&inbound.rinstance = %5

Then I can use that in the 2nd Dial Plan Deploy Pattern, like this:

$request= INVITE sip:%1@%4;rinstance = &inbound.rinstance SIP/2.0

This should work, shouldn't it?

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Thu Nov 02, 2023 7:38 pm    Post subject: Reply with quote

[quote="JRayfield"]Thank you Laurie.

I was pretty close with my last try. I forgot the "SIP/2.0".

So I have, in the 1st Deploy Pattern:

&inbound.to = sip:%1@%4
$rtp = %3
$auth = false
$request = INVITE sip:%1@%4;rinstance=%5 SIP/2.0
$continue = true

This seems to work. Here's the INVITE as it's sent to the 3CX server:

INVITE sip:DID-Number@3CX-Server-IP:5060;rinstance=b3839ecac2dc397c SIP/2.0

In comparing the rinstance value in the 3CX REGISTRATION messages, with the rinstance value that is added to the INVITE messages sent to the 3CX server, they match.

So it looks like this is all working. I did not have to add the new $reqest line into the 2nd or 3rd Dial Plans. I also did not make use of a variable for the rinstance value.

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Thu Nov 02, 2023 9:51 pm    Post subject: Reply with quote

Smile
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1