Plivo Inbound trunking on Freepbx (Inbound routes)

Thanks for that Lorne,

Very useful:

My sanitised output is:

pbxa*CLI> sip set debug peer PLIVOTRUNK000
SIP Debugging Enabled for IP: XX.X.XXX.123
Reliably Transmitting (NAT) to XX.X.XXX.123:5060:
OPTIONS sip:phone.plivo.com SIP/2.0
Via: SIP/2.0/UDP 51.254.204.89:5160;branch=z9hG4bK33014126;rport
Max-Forwards: 70
From: "Unknown" <sip:[email protected]:5160>;tag=as02256083
To: <sip:phone.plivo.com>
Contact: <sip:[email protected]:5160>
Call-ID: [email protected]:5160
CSeq: 102 OPTIONS
User-Agent: FPBX-13.0.190.9(13.13.1)
Date: Fri, 06 Jan 2017 22:35:43 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


---

<--- SIP read from UDP:XX.X.XXX.123:5060 --->
SIP/2.0 484 Address Incomplete
Via: SIP/2.0/UDP XX.X.XXX..89:5160;branch=z9hG4bK33014126;rport=5160;received=XX.X.XXX..89
From: "Unknown" <sip:[email protected]:5160>;tag=as02256083
To: <sip:phone.plivo.com>;tag=474ffd7c21aee331a23ec34c5cbcdf9d.1ab7
Call-ID: [email protected]:5160
CSeq: 102 OPTIONS
Server: kamailio (4.3.6 (x86_64/linux))
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---
Really destroying SIP dialog '[email protected]:5160' Method: OPTIONS

<--- SIP read from UDP:XX.X.XXX.123:5060 --->
INVITE sip:[email protected]:5160;transport=UDP SIP/2.0
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0
Via: SIP/2.0/UDP 52.59.63.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Max-Forwards: 40
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Contact: <sip:[email protected]:5080>
User-Agent: Plivo
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, refer
Privacy: none
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 300
P-Asserted-Identity: "+447877000000" <sip:[email protected]>
P-hint: outbound

v=0
o=FreeSWITCH 1483719044 1483719045 IN IP4 XX.X.XXX.228
s=FreeSWITCH
c=IN IP4 XX.X.XXX.228
t=0 0
m=audio 23118 RTP/AVP 0 8 102 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:102 SPEEX/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
<------------->
--- (20 headers 13 lines) ---
Sending to XX.X.XXX.123:5060 (NAT)
Sending to XX.X.XXX.123:5060 (NAT)
Using INVITE request as basis request - 5d4717db-81da-4321-b9cf-24d2d215be6b
Found peer 'PLIVOTRUNK000' for '+447877000000' from XX.X.XXX.123:5060
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 102
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format PCMA for ID 8
Found audio description format SPEEX for ID 102
Found audio description format telephone-event for ID 101
Capabilities: us - (gsm|ulaw|g722), peer - audio=(ulaw|alaw|speex)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port XX.X.XXX.228:23118
Looking for s in custom-get-did-from-plivo (domain XX.X.XXX..89)
sip_route_dump: route/path hop: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>

<--- Transmitting (NAT) to XX.X.XXX.123:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Length: 0


<------------>
    -- Executing [s@custom-get-did-from-plivo:1] NoOp("SIP/PLIVOTRUNK000-00000095", "Fixing DID using information from PLIVO TO header") in new stack
    -- Executing [s@custom-get-did-from-plivo:2] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=<sip:[email protected];transport=udp>") in new stack
    -- Executing [s@custom-get-did-from-plivo:3] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=<sip:PLIVOTRUNK000") in new stack
    -- Executing [s@custom-get-did-from-plivo:4] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=PLIVOTRUNK000") in new stack
    -- Executing [s@custom-get-did-from-plivo:5] Set("SIP/PLIVOTRUNK000-00000095", "pseudodid=DDI I WANT TO ASSIGN") in new stack


Audio is at 14882
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to XX.X.XXX.123:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Type: application/sdp
Require: timer
Content-Length: 252

v=0
o=root 611487133 611487133 IN IP4 XX.X.XXX..89
s=Asterisk PBX 13.13.1
c=IN IP4 XX.X.XXX..89
t=0 0
m=audio 14882 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<------------>
Retransmitting #1 (NAT) to XX.X.XXX.123:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.3bade1a8fe2f742c4459b0271e91b961.0;received=XX.X.XXX.123;rport=5060
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKF951p7geyySeD
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF;did=da2.0b9>
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 INVITE
Server: FPBX-13.0.190.9(13.13.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: <sip:[email protected]:5160>
Content-Type: application/sdp
Require: timer
Content-Length: 252

v=0
o=root 611487133 611487133 IN IP4 XX.X.XXX..89
s=Asterisk PBX 13.13.1
c=IN IP4 XX.X.XXX..89
t=0 0
m=audio 14882 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

---

<--- SIP read from UDP:XX.X.XXX.123:5060 --->
ACK sip:[email protected]:5160 SIP/2.0
Record-Route: <sip:XX.X.XXX.123;lr=on;ftag=1mp5v29H0mtpF>
Via: SIP/2.0/UDP XX.X.XXX.123:5060;branch=z9hG4bK7819.8a361f586d9cdd51c66a3c87e3e48b56.0
Via: SIP/2.0/UDP XX.X.XXX.228:5080;received=XX.X.XXX.228;rport=5080;branch=z9hG4bKgjZtr21HU7F1r
Max-Forwards: 69
From: "+447877000000" <sip:[email protected]>;tag=1mp5v29H0mtpF
To: <sip:[email protected];transport=udp>;tag=as6cebb232
Call-ID: 5d4717db-81da-4321-b9cf-24d2d215be6b
CSeq: 101535016 ACK
Contact: <sip:[email protected]:5080>
Content-Length: 0

<------------->

As you can see, the To: in the header is my Sip uri from my plivo endpoint.

Plivo just simply does not pass the DID when sending a call to my FreePBX.

However i have managed to get a single number to route so far.:
I created a custom context to pull the Siptrunk URI name into the DDI and then replace it with the DID i want freepbx to see.

It seems i will need to do Seperate trunks for each DID and seperate contexts!!! man this is so rubbish!

2 Likes

is there an alternative to Easytrunk by plivo so i could just pass incomming calls to @MYFREEPBXDOMAIN.COM?

could i do this?

There is an excellent alternative trunk service here:

Hi Lorne, thanks for that, sip station seems to be an ITSP/sip trunk provider, that seems only to have USA/Canada Numbers.

Easytrunk is a python script by plivo that is a piece of code that runs on a server and accepts incoming sip URI requests and forwards them on.

What i meant was is there an alternative hosted code that would allow me to pass sip calls directly to my pbx.

No offense, but are you a stock holder in Plivo? There are so many easy-to-use VOIP providers out there that putting up with this silliness just seems like self-flagellation.

SIP Station
Voip Innovations
Alcazar Networks

and a hundred more all have good reputations and make the task of getting a SIP connection working SO much simpler than having to set up a custom-developers account…

No offence taken.

no, i am not a stock holder, and I have a working solution with A company called number group who I have used for many years.

However number group do not have the infrastructure to allow inbound and outbound SMS messages over there sip numbers,

When researching the best platforms/tools to use for SMS messages incoming and outgoing with a global presence, the options where quite a clear cut, Twilio, Nexmo, Bandwidth.com, And live.

Most ITSP’s are for CALLS and sip trunks are for voice traffic; I need something in the first sense that can send and receive text messages, and also make and receive calls, specifically with English numbers.

Right, now that I’ve explained myself, 1< Twilio is very expensive for what it is, and its virtual British mobile numbers do not allow inbound/outbound SMS like plivo does,
2, every SMS provider that allows inbound/outbound SMS either charges a LOT for a number dedicated and they also do not permit me to use it as a sip trunk.

  1. Bandwidth.com is pretty much focused on the USA/Canada only and do not have number ranges for non-US customers (I’m talking API access here)

  2. Nexmo was a close 2nd to Plivo regarding my choice for the provider, but Nexmo’s documentation is not as good, and they are a bit pricier.

  • So do you have any suggestions of any CHEAP, SOLID, Sip trunk providers that have inbound/Outbound SMS capability and allow me to rent UK mobile numbers and Europe numbers, that have Low call costs and small SMS costs allow inbound & outbound, are scalable and have high uptime & reliability?

My application is for ultimately to have UK Mobile numbers that can send/receive SMS messages, and can send & Recieve calls.

Virtual mobile phone numbers basically (Not the virtual landline of your typical sip trunk/office phone)

so if you have a better alternative then Plivo i would love to find out (That does not charge me a ridiculous amount)

So no, i do not have a stake in Plivo, and yes it is crazy difficult to get it to do what i want to do, but from my research, any of the providers i looked at (Plivo, Twillo, Nexmo,Broadband.com) require me to build around there platform.

So need SMS+calls In & Out, for cheap price with UK numbers or global.

suggestions please?

Call VoipInnovations and ask for Brian. He was able to help out a guy that was looking for Brazilian services, even though they are in Canada and Pennsylvania.

They are doing SMS (I have SMS enabled on one of my trunks) and they are reasonably priced.

Thanks for that, Now back to getting plivo to pass incoming DDI, the headers seem to pass the Siptrunk name (the bit that goes [email protected])
but this is obviously going to be the same for any number unless i use a different endpoint for every number.

is there any way around this?