How to Originate Outbound Calls through an External SIP Provider (i.e. Twilio)

960 views
Skip to first unread message

case...@gmail.com

unread,
Jun 30, 2014, 7:55:30 PM6/30/14
to 2600h...@googlegroups.com
Hi Everyone,

I've completely ran out of ideas, and I need some help! 
I'm trying to originate a call using ecallmgr through AMQP to a 3rd party SIP provider (e.g. Twilio). This works when calling soft phones connected to my local Kazoo instance, but when I try to use the realm associated with the outbound SIP provider, I get the error "DESTINATION_OUT_OF_ORDER". I've spent quite a few hours researching and troubleshooting, and I'm not sure what to do from here. Does anyone know how to originate a call through ecallmgr to an external SIP provider?

Thanks for the help!!

Casey

Here are the details:
I ran this line to setup my offnet location in couchdb: sup whapps_maintenance migrate

I created a new document under offnet in couchdb according to this article: https://2600hz.atlassian.net/wiki/display/Dedicated/Global+Resources

{
   "_id": "b4703e63ecbf6d55e1e056c6274210ab",
   "_rev": "6-fba8c05e85c4eba640c8ecf3408c2ea2",
   "pvt_type": "resource",
   "name": "Twilio",
   "enabled": true,
   "flags": [
   ],
   "weight_cost": 30,
   "rules": [
       "^\\+1(\\d{10})$"
   ],
   "gateways": [
       {
           "server": "<redacted>.sip.twilio.com",
           "realm": "<redacted>.sip.twilio.com",
           "username": "<redacted>",
           "password": "<redacted>"
           "prefix": "+",
           "suffix": "",
           "codecs": [
               "G729",
               "PCMU",
               "PCMA"
           ],
           "progress_timeout": "30",
           "enabled": true
       }
   ],
   "grace_period": 5,
   "formatters": {
       "request": [
           {
               "regex": "^\\+?1?\\d{6}(\\d{4})$",
               "prefix": "",
               "suffix": ""
           }
       ]
   }
}





When I send an AMQP packet, I get this error response:
{
  "Call-ID": "b3d3eb08-00ad-11e4-b0e0-3d8d7aaa3173",
  "Request": {
    "Custom-Channel-Vars": {},
    "Endpoints": [
      {
        "Ignore-Completed-Elsewhere": "true",
        "SIP-Headers": {},
        "Codecs": [
          "G729",
          "PCMU",
          "PCMA"
        ],
        "Endpoint-Timeout": 30,
        "Outbound-Caller-ID-Name": "CallMeMaybe",
        "Outbound-Caller-ID-Number": "42",
        "To": "<phone number redacted>@<redacted>.sip.twilio.com"
      }
    ],
    "Application-Name": "park",
    "Originate-Immediate": true,
    "Event-Category": "resource",
    "Event-Name": "originate_req",
    "Continue-On-Fail": false,
    "SIP-Headers": {},
    "App-Version": "0.0.1",
    "App-Name": "CallMeMaybe",
    "Msg-ID": "ddb9e505-cf91-41ee-92be-87c648477830",
    "Server-ID": "CallMeMaybe_ReceiveQueue_ecd87ecd-49cf-4c47-95de-fd9bfe8ccd49"
  },
  "Error-Message": "DESTINATION_OUT_OF_ORDER\n",
  "Server-ID": "",
  "Msg-ID": "ddb9e505-cf91-41ee-92be-87c648477830",
  "App-Version": "0.8.0",
  "App-Name": "ecallmgr",
  "Event-Name": "originate_resp",
  "Event-Category": "error"
}



At the same time, FS_CLI reports:
2014-06-30 23:24:37.379069 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.379069 [DEBUG] kazoo_event_stream.c:158 Starting erlang event stream 0x7fcf54010d00 on 0.0.0.0:38710 for ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.379069 [DEBUG] kazoo_event_stream.c:459 Adding event binding b3cd185a-00ad-11e4-b0df-3d8d7aaa3173 to stream 0x7fcf54010d00 for ecal...@testkazoo.2600hz.org <2.1541.0>: CUSTOM loopback::bowout
2014-06-30 23:24:37.379069 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.418510 [INFO] kazoo_node.c:627 exec: create_uuid( )
2014-06-30 23:24:37.418510 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.438561 [INFO] kazoo_node.c:627 exec: create_uuid( )
2014-06-30 23:24:37.438561 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.458746 [INFO] kazoo_node.c:627 exec: originate({ecallmgr_Fetch-ID='b701fa5fe0220d4fa4cc83d7df47d176',ecallmgr_Ecallmgr-Node='ecal...@testkazoo.2600hz.org',continue_on_fail='false',loopback_bowout_on_execute='true',local_var_clobber='true'} &park())
2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:2061 Parsing global variables
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Ecallmgr-Node]=[ecal...@testkazoo.2600hz.org]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [continue_on_fail]=[false]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [loopback_bowout_on_execute]=[true]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [local_var_clobber]=[true]
2014-06-30 23:24:37.458746 [WARNING] switch_ivr_originate.c:2080 No origination URL specified!
2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:3639 Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]
2014-06-30 23:24:37.458746 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.458746 [DEBUG] kazoo_node.c:1019 Received erlang exit notice for ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.879514 [DEBUG] kazoo_event_stream.c:235 Shutting down erlang event stream 0x7fcf54010d00
2014-06-30 23:24:37.879514 [NOTICE] switch_event.c:2073 Event Binding deleted for b3cd185a-00ad-11e4-b0df-3d8d7aaa3173:CUSTOM

Luis Azedo

unread,
Jun 30, 2014, 8:09:18 PM6/30/14
to 2600h...@googlegroups.com
can you post your AMQP packet ?


--
You received this message because you are subscribed to the Google Groups "2600hz-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 2600hz-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



case...@gmail.com

unread,
Jul 1, 2014, 11:14:19 AM7/1/14
to 2600h...@googlegroups.com
Sure. Here it is:

{
    "Custom-Channel-Vars": {},
    "Endpoints": [
      {
        "Ignore-Completed-Elsewhere": "true",
        "SIP-Headers": {},
        "Codecs": [
          "G729",
          "PCMU",
          "PCMA"
        ],
        "Endpoint-Timeout": 30,
        "Outbound-Caller-ID-Name": "CallMeMaybe",
        "Outbound-Caller-ID-Number": "42",
        "To": "<phone number redacted>@<redacted>.sip.twilio.com"
      }
    ],
    "Application-Name": "park",
    "Originate-Immediate": true,
    "Event-Category": "resource",
    "Event-Name": "originate_req",
    "Continue-On-Fail": false,
    "SIP-Headers": {},
    "App-Version": "0.0.1",
    "App-Name": "CallMeMaybe",
    "Msg-ID": "ddb9e505-cf91-41ee-92be-87c648477830",
    "Server-ID": "CallMeMaybe_ReceiveQueue_ecd87ecd-49cf-4c47-95de-fd9bfe8ccd49"
  }


The above packet is a modified version of this packet which works with calling softphones connected directly.
{
  "Custom-Channel-Vars": {},
  "Endpoints": [
    {
      "Ignore-Completed-Elsewhere": "true",
      "SIP-Headers": {},
      "Codecs": [
        "G729",
        "PCMU",
        "PCMA"
      ],
      "Endpoint-Timeout": 30,
      "Outbound-Caller-ID-Name": "CallMeMaybe",
      "Outbound-Caller-ID-Number": "42",
      "To-Realm": "sip.testkazoo.2600hz.org",
      "To-User": "win",
      "Invite-Format": "username"
    }
  ],
  "Application-Name": "park",
  "Originate-Immediate": true,
  "Event-Category": "resource",
  "Event-Name": "originate_req",
  "Continue-On-Fail": false,
  "SIP-Headers": {},
  "App-Version": "0.0.1",
  "App-Name": "CallMeMaybe",
  "Msg-ID": "4dd2c53a-ad78-499b-819d-8e19c7f8472a",
  "Server-ID": "CallMeMaybe_ReceiveQueue_ecd87ecd-49cf-4c47-95de-fd9bfe8ccd49"
}


Thanks again!
Casey
2014-06-30 23:24:37.458746 [INFO] kazoo_node.c:627 exec: originate({ecallmgr_Fetch-ID='b701fa5fe0220d4fa4cc83d7df47d176',ecallmgr_Ecallmgr-Node='ecall...@testkazoo.2600hz.org',continue_on_fail='false',loopback_bowout_on_execute='true',local_var_clobber='true'} &park())
2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:2061 Parsing global variables
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Ecallmgr-Node]=[ecallm...@testkazoo.2600hz.org]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [continue_on_fail]=[false]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [loopback_bowout_on_execute]=[true]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [local_var_clobber]=[true]
2014-06-30 23:24:37.458746 [WARNING] switch_ivr_originate.c:2080 No origination URL specified!
2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:3639 Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]
2014-06-30 23:24:37.458746 [DEBUG] kazoo_node.c:1091 Sent erlang message to ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.458746 [DEBUG] kazoo_node.c:1019 Received erlang exit notice for ecal...@testkazoo.2600hz.org <2.1541.0>
2014-06-30 23:24:37.879514 [DEBUG] kazoo_event_stream.c:235 Shutting down erlang event stream 0x7fcf54010d00
2014-06-30 23:24:37.879514 [NOTICE] switch_event.c:2073 Event Binding deleted for b3cd185a-00ad-11e4-b0df-3d8d7aaa3173:CUSTOM

James Aimonetti

unread,
Jul 1, 2014, 12:12:24 PM7/1/14
to 2600h...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 06/30/2014 04:55 PM, case...@gmail.com wrote:
> Hi Everyone,
>
> I've completely ran out of ideas, and I need some help! I'm trying
> to originate a call using ecallmgr through AMQP to a 3rd party SIP
> provider (e.g. Twilio). This works when calling soft phones
> connected to my local Kazoo instance, but when I try to use the
> realm associated with the outbound SIP provider, I get the error
> "DESTINATION_OUT_OF_ORDER". I've spent quite a few hours
> researching and troubleshooting, and I'm not sure what to do from
> here. Does anyone know how to originate a call through ecallmgr to
> an external SIP provider?
>
> Thanks for the help!!
>
> Casey
>
> Here are the details: I ran this line to setup my offnet location
> in couchdb: *sup whapps_maintenance migrate* (Found in this thread:
>
> https://groups.google.com/forum/#!searchin/2600hz-dev/offnet/2600hz-dev/5R9k7P-tZLw/N9QANetp1noJ
>
>
)
>
> I created a new document under offnet in couchdb according to this
> article:
> https://2600hz.atlassian.net/wiki/display/Dedicated/Global+Resources
>
> { "_id": "b4703e63ecbf6d55e1e056c6274210ab", "_rev":
> "6-fba8c05e85c4eba640c8ecf3408c2ea2", "pvt_type": "resource",
> "name": "Twilio", "enabled": true, "flags": [ ], "weight_cost":
> 30, "rules": [ "^\\+1(\\d{10})$" ],

This seems like it will match +1(10 digits), then prefix it with +,
which may not be what you want.

> "gateways": [ { "server": "<redacted>.sip.twilio.com", "realm":
> "<redacted>.sip.twilio.com", "username": "<redacted>", "password":
> "<redacted>" "prefix": "+", "suffix": "", "codecs": [ "G729",
> "PCMU", "PCMA" ], "progress_timeout": "30", "enabled": true } ],
> "grace_period": 5, "formatters": { "request": [ { "regex":
> "^\\+?1?\\d{6}(\\d{4})$", "prefix": "", "suffix": "" } ] } }
>
>

I assume you're using wapi_offnet_resource.erl as your AMQP guide?
You can see no endpoints are on the end of this originate command.
Would need to see the ecallmgr_originate logs as well.

> 2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:2061
> Parsing global variables 2014-06-30 23:24:37.458746 [DEBUG]
> switch_event.c:1661 Parsing variable
> [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176] 2014-06-30
> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
> [ecallmgr_Ecallmgr-Node]=[ecal...@testkazoo.2600hz.org] 2014-06-30
> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
> [continue_on_fail]=[false] 2014-06-30 23:24:37.458746 [DEBUG]
> switch_event.c:1661 Parsing variable
> [loopback_bowout_on_execute]=[true] 2014-06-30 23:24:37.458746
> [DEBUG] switch_event.c:1661 Parsing variable
> [local_var_clobber]=[true] *2014-06-30 23:24:37.458746 [WARNING]
> switch_ivr_originate.c:2080 No origination URL specified!*
> *2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:3639
> Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]*
> 2014-06-30 23:24:37.458746 [DEBUG] kazoo_node.c:1091 Sent erlang
> message to ecal...@testkazoo.2600hz.org <2.1541.0> 2014-06-30
> 23:24:37.458746 [DEBUG] kazoo_node.c:1019 Received erlang exit
> notice for ecal...@testkazoo.2600hz.org <2.1541.0> 2014-06-30
> 23:24:37.879514 [DEBUG] kazoo_event_stream.c:235 Shutting down
> erlang event stream 0x7fcf54010d00 2014-06-30 23:24:37.879514
> [NOTICE] switch_event.c:2073 Event Binding deleted for
> b3cd185a-00ad-11e4-b0df-3d8d7aaa3173:CUSTOM
>


- --
James Aimonetti
Lead Systems Architect / Impressionable Scallywag
"I thought I fixed that"

2600Hz | http://2600hz.com
sip:ja...@2600hz.com
tel:415.886.7905
irc:mc_ @ freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlOy3eIACgkQ54NxaUq7OmBztQEAibrqTbQ+ta/eA17GxaBGDm3K
K+98IFZN4nF+zTUmvoYA/3xi0dLCnY3SJSk78oA18Y9a4mOVh731oFVZmXMjdKJd
=3BYg
-----END PGP SIGNATURE-----

case...@gmail.com

unread,
Jul 2, 2014, 3:22:07 PM7/2/14
to 2600h...@googlegroups.com, case...@gmail.com
Hi James,

You brought my attention to that ecallmgr probably wasn't assigning any endpoints. I dug into how ecallmgr was trying to make the sofia call to FS, and I found in ecallmgr_util that an exception was being thrown when it was building the command string, because I wasn't including a couple parameters that it was expecting (though it passed the JSON verification in wapi_offnet_resource). On line 500 in ecallmgr_util it has:

endpoint_key(Endpoint) ->
    [wh_json:get_value(<<"Invite-Format">>, Endpoint)
     ,wh_json:get_value(<<"To-User">>, Endpoint)
     ,wh_json:get_value(<<"To-Realm">>, Endpoint)
     ,wh_json:get_value(<<"To-DID">>, Endpoint)
     ,wh_json:get_value(<<"Route">>, Endpoint)
    ].

I added each of those parameters and also "To-IP" (mentioned on line 457), and it started working like a charm!

Thanks again for your help!

Casey
2014-06-30 23:24:37.458746 [INFO] kazoo_node.c:627 exec: originate({ecallmgr_Fetch-ID='b701fa5fe0220d4fa4cc83d7df47d176',ecallmgr_Ecallmgr-Node='ecall...@testkazoo.2600hz.org',continue_on_fail='false',loopback_bowout_on_execute='true',local_var_clobber='true'} &park())
2014-06-30 23:24:37.458746 [DEBUG] switch_ivr_originate.c:2061 Parsing global variables
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176]
2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable [ecallmgr_Ecallmgr-Node]=[ecallm...@testkazoo.2600hz.org]

Sunny Wu

unread,
Oct 15, 2014, 9:03:52 AM10/15/14
to 2600h...@googlegroups.com, case...@gmail.com
Hi Casey,

looks I got similar problem but I don't get how you solve this here.
1) How can I peak  into a AMQP packet?
2) Can you explain little bit more the solution here under, where to make the definitions?

Thanks,
Sunny


Op woensdag 2 juli 2014 21:22:07 UTC+2 schreef Casey Johnson:

Sunny Wu

unread,
Oct 16, 2014, 1:09:00 PM10/16/14
to 2600h...@googlegroups.com, case...@gmail.com
Hi Casey,

thanks for you swift answers and detailed AMQP packet inspection, I need take close look myself how that is working.

For your 2nd answer I will explanation a bit my situation. It switch recently from carrier, which is not Twillo but they expect me pass a international prefix not with + but 00. With my previous carrier to dial out to local country it was ok to use 0 following rest of numbers without any prefix.
I live in NL and now I need to dial 0031 with rest of numbers also for local country calls.

I wish to have some number translation rules which I thought to use with formatters rules in the offnet connection document you mentioned. But that didn't help as I made the formatters rules and checked with up 'stepswitch_maintenance process_number' command.

I thought you may find a solution for that to do something with the To-DID value.

Anyway the formatters rule didn't changed anything for me. 
Do you have further clues for me.

Thanks.
Sunny
 

Op woensdag 15 oktober 2014 15:03:52 UTC+2 schreef Sunny Wu:

James Aimonetti

unread,
Oct 16, 2014, 1:23:21 PM10/16/14
to 2600h...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Sunny,

For numbers coming into Kazoo, from a phone, carrier, etc, Kazoo needs
to be able to know when to convert (using reconcile_regex) to E164,
and then how to convert to E164 (using the e164_convertors).

Read more about that here:
https://github.com/2600hz/kazoo/blob/master/applications/crossbar/doc/internationalization/numbers.md

For going out from Kazoo to a carrier, the resource doc specifies the
"rules" regex for when to use a carrier. Within the gateway section,
you can specify prefix/suffix to work in conjunction with a capture
group in the "rules" regex to format the number as your carrier
expects it.

Read more about carriers here:
https://2600hz.atlassian.net/wiki/display/Dedicated/Global+Resources

So basically, if your carrier is routing US DIDs, your "rules" for
that carrier would be "^\\+?1?(\\d{10})$". This will capture the last
10 digits of a US DID in E164, 1NPAN, or NPAN. You can then add a
"prefix" to prepend whatever you need.

If you can supply a concrete use case, we can help you refine these
rules further to match your needs. Something like:

I typically dial XXX and my carrier expects it to be sent to them as
YYY. We can then see how to get XXX to E164 and then E164 to YYY for
the carrier.

James
>>>> location in couchdb: *sup whapps_maintenance migrate* (Found
ecal...@testkazoo.2600hz.org',continue_on_fail='false',loopback_bowout_on_execute='true',local_var_clobber='true'}

>>>> &park()) 2014-06-30 23:24:37.458746 [DEBUG]
>>>> switch_ivr_originate.c:2061 Parsing global variables
>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>> Parsing variable
>>>> [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176]
>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>> Parsing variable
>>>> [ecallmgr_Ecallmgr-Node]=[ecal...@testkazoo.2600hz.org]
>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>> Parsing variable [continue_on_fail]=[false] 2014-06-30
>>>> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
>>>> [loopback_bowout_on_execute]=[true] 2014-06-30
>>>> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
>>>> [local_var_clobber]=[true] *2014-06-30 23:24:37.458746
>>>> [WARNING] switch_ivr_originate.c:2080 No origination URL
>>>> specified!* *2014-06-30 23:24:37.458746 [DEBUG]
>>>> switch_ivr_originate.c:3639 Originate Resulted in Error
>>>> Cause: 27 [DESTINATION_OUT_OF_ORDER]* 2014-06-30
>>>> 23:24:37.458746 [DEBUG] kazoo_node.c:1091 Sent erlang message
>>>> to ecal...@testkazoo.2600hz.org <2.1541.0> 2014-06-30
>>>> 23:24:37.458746 [DEBUG] kazoo_node.c:1019 Received erlang
>>>> exit notice for ecal...@testkazoo.2600hz.org <2.1541.0>
>>>> 2014-06-30 23:24:37.879514 [DEBUG] kazoo_event_stream.c:235
>>>> Shutting down erlang event stream 0x7fcf54010d00 2014-06-30
>>>> 23:24:37.879514 [NOTICE] switch_event.c:2073 Event Binding
>>>> deleted for b3cd185a-00ad-11e4-b0df-3d8d7aaa3173:CUSTOM
>>>>
>>>>
>


- --
James Aimonetti
Lead Systems Architect / Impressionable Scallywag
"I thought I fixed that"

2600Hz | http://2600hz.com
sip:ja...@2600hz.com
tel:415.886.7905
irc:mc_ @ freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUP/8HAAoJENTKa+JPXCVgt8cH/Rh2+0RDd8yEhycN19ACIeur
enu1rwfxvxdUnBilpomXkDQJc4U9/6AMMSiVVfo5P3HEUkzk3S2SOdY5nZNB6aCT
oXvqFFMTiSXr+q4EutJ733tNJw+bcOTOtG/Go0sSqf9KgAWPSD++gwIVOFiTZUq4
TOyjsU9CFUrAxeUCXVyEttjlXtBwhXWhhlhOjfQxWVcRFB2pGTl9bDjx2RHaEpwv
cclVhRgWHdSWPiWjTahuUBPwwgC+k9/GoqdUO3Gi2GRVbk8dpjgpNT0/I9wNQAWP
FoN5FtMnDzUXCyknArfSjIGr+rvYSWXAvKfDfew2dGcw4mp4Wk8k4VpCtL+CGJY=
=xjCW
-----END PGP SIGNATURE-----

Sunny Wu

unread,
Oct 16, 2014, 3:03:06 PM10/16/14
to 2600h...@googlegroups.com, ja...@2600hz.com
Hi James,

thanks for your help. I did consult the documentation. Inbound is no problem. For outgoing I think I have followed the instructions. Please correct me if I was wrong.

See my offnet document:

{
   "weight_cost": "50",
   "enabled": true,
   "gateways": [
       {
           "prefix": "",
           "codecs": [
               "PCMA"
           ],
           "progress_timeout": "6",
           "server": "sip.mycarrier.com",
           "username": "xxxxx",
           "password": "xxxxx",
           "realm": "sip.mycarrier.com",
           "format_from_uri": false,
           "suffix": ""
       }
   ],
   "rules": [
       "\\d+"
   ],
   "formatters": {
       "request": [
           {
               "regex": "^0(\\d{9})$",
               "prefix": "0031",
               "suffix": ""
           }
       ]
   },
   "caller_id_options": {
       "type": "external"
   },
   "type": "local",
   "name": "Mycarrier",
   "emergency": false,
   "grace_period": 5,
   "flags": [
   ],
   "pvt_type": "resource"
}

I wish to dialout any number so rules is "\\d+" which works fine.
If I dial 0 with 9 digits following I want to prefix the 9 digits with "0031" so I made the formatters regex request: "^0(\\d{9})$" 

I did sup stepswitch_maintenance reload_resources after changed the document.

Than I place a call to 0201234567 
See the SIP flow here under:

============
   ------------------------------------------------------------------------
recv 443 bytes from udp/[77.72.xxx.xxx]:5060 at 20:33:30.924679:
   ------------------------------------------------------------------------
   SIP/2.0 100 Trying
   Via: SIP/2.0/UDP 192.168.88.20:11000;rport;branch=z9hG4bKHaBXgUjeray1m
   From: "ME" <sip:+31297...@192.168.88.20>;tag=ga2cN30QDXr7j
   Contact: sip:02012...@77.72.xxx.xxx:5060
   Call-ID: ed85a90e-5562-11e4-9d1c-2907737af51c
   CSeq: 66406142 INVITE
   Server: (Very nice Sip Registrar/Proxy Server)
   Allow: ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE
   Content-Length: 0

   ------------------------------------------------------------------------
recv 716 bytes from udp/[77.72.xxx.xxx]:5060 at 20:33:30.998331:
   ------------------------------------------------------------------------
   SIP/2.0 183 Session progress
   Via: SIP/2.0/UDP 192.168.88.20:11000;rport;branch=z9hG4bKHaBXgUjeray1m
   From: "ME" <sip:+31297...@192.168.88.20>;tag=ga2cN30QDXr7j
   To: <sip:02012...@sip.mycarrier.com>;tag=360313ac543ed5d93532b
   Contact: sip:02012...@77.72.xxx.xxx:5060
   Call-ID: ed85a90e-5562-11e4-9d1c-2907737af51c
   CSeq: 66406142 INVITE
   Server: (Very nice Sip Registrar/Proxy Server)
   Allow: ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE
   Content-Type: application/sdp
   Content-Length: 204

==========

The call didn't went through as it should go To: <sip:003120...@sip.mycarrier.com> and not To: <sip:02012...@sip.mycarrier.com> as above.

Hope you can help me solve this.
Thanks.
Sunny



Op donderdag 16 oktober 2014 19:23:21 UTC+2 schreef James Aimonetti:
>>>> [ecallmgr_Ecallmgr-Node]=[ecallm...@testkazoo.2600hz.org]
>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>> Parsing variable [continue_on_fail]=[false] 2014-06-30
>>>> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
>>>>  [loopback_bowout_on_execute]=[true] 2014-06-30
>>>> 23:24:37.458746 [DEBUG] switch_event.c:1661 Parsing variable
>>>>  [local_var_clobber]=[true] *2014-06-30 23:24:37.458746
>>>> [WARNING] switch_ivr_originate.c:2080 No origination URL
>>>> specified!* *2014-06-30 23:24:37.458746 [DEBUG]
>>>> switch_ivr_originate.c:3639 Originate Resulted in Error
>>>> Cause: 27 [DESTINATION_OUT_OF_ORDER]* 2014-06-30
>>>> 23:24:37.458746 [DEBUG] kazoo_node.c:1091 Sent erlang message
>>>>  to ecal...@testkazoo.2600hz.org <2.1541.0> 2014-06-30
>>>> 23:24:37.458746 [DEBUG] kazoo_node.c:1019 Received erlang
>>>> exit notice for ecal...@testkazoo.2600hz.org <2.1541.0>
>>>> 2014-06-30 23:24:37.879514 [DEBUG] kazoo_event_stream.c:235
>>>> Shutting down erlang event stream 0x7fcf54010d00 2014-06-30
>>>> 23:24:37.879514 [NOTICE] switch_event.c:2073 Event Binding
>>>> deleted for b3cd185a-00ad-11e4-b0df-3d8d7aaa3173:CUSTOM
>>>>
>>>>
>


- --
James Aimonetti
Lead Systems Architect / Impressionable Scallywag
"I thought I fixed that"

2600Hz | http://2600hz.com

James Aimonetti

unread,
Oct 16, 2014, 3:19:50 PM10/16/14
to Sunny Wu, 2600h...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"formatters" only apply to inbound from the carrier.

You need to capture the 9 digits as part of your "rules" regex and put
the prefix in the gateways.prefix.

I don't think any of the docs mention using formatters for outbound;
please link to it if you read that somewhere so we can correct it!
> <javascript:>',continue_on_fail='false',loopback_bowout_on_execute='true',local_var_clobber='true'}
>
>
>
>>>>>>> &park()) 2014-06-30 23:24:37.458746 [DEBUG]
>>>>>>> switch_ivr_originate.c:2061 Parsing global variables
>>>>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>>>>> Parsing variable
>>>>>>> [ecallmgr_Fetch-ID]=[b701fa5fe0220d4fa4cc83d7df47d176]
>>>>>>> 2014-06-30 23:24:37.458746 [DEBUG] switch_event.c:1661
>>>>>>> Parsing variable
>>>>>>> [ecallmgr_Ecallmgr-Node]=[ecal...@testkazoo.2600hz.org
>>>>>>> <javascript:>]
sip:ja...@2600hz.com
tel:415.886.7905
irc:mc_ @ freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUQBpTAAoJENTKa+JPXCVgZVkH/R7flj1mzvV33NZXkABApK6w
1w6DNfgj49JTsTUg/icaAgr/6B/h6DtBbqqo8DAxJE5ETPd7xQY2SM0p4MDLxXmW
aGKzL9jdkk3qfeGsOLEVIo6zsgPDgGg59sUD3J4o2STblk36LP97yTgj1NUFyWzK
TwCT81DG3BMQL0LCcEV7ojLFQme1pEHTEcMDIyCNnX900xEjTqiwY1z1rKUddkv0
GLt9cIEetFX/ykFi/f6PcfcJrEDEjhKQLsl4tSCohfPl5apRvc8ZqIpoNKo/NyP4
e3L+4OTObsQlYg7uKBtrYa1G313znsyUcM0IYsnRXT403+CG+pUR4kiAQj9aGa4=
=Ep/5
-----END PGP SIGNATURE-----

Sunny Wu

unread,
Oct 16, 2014, 4:22:32 PM10/16/14
to 2600h...@googlegroups.com, sh...@proficom.nl, ja...@2600hz.com
thanks James, all clear now and it is working as instructed.
I read it once again and it says formatters are for incoming. As I use offnet document for outgoing only I maybe mislead by the samples in there with the formatters rules. 

Is it correct that the offnet document can be used for incoming carriers too?

Cheers.
Sunny

Op donderdag 16 oktober 2014 21:19:50 UTC+2 schreef James Aimonetti:
> <sip:+312...@192.168.88.20>;tag=ga2cN30QDXr7j To:
> <sip:020...@sip.mycarrier.com> Contact:
> sip:02012...@77.72.xxx.xxx:5060 Call-ID:
> ed85a90e-5562-11e4-9d1c-2907737af51c CSeq: 66406142 INVITE Server:
> (Very nice Sip Registrar/Proxy Server) Allow:
> ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE Content-Length:
> 0
>
> ------------------------------------------------------------------------
>
>
recv 716 bytes from udp/[77.72.xxx.xxx]:5060 at 20:33:30.998331:
> ------------------------------------------------------------------------
>
>
SIP/2.0 183 Session progress
> Via: SIP/2.0/UDP
> 192.168.88.20:11000;rport;branch=z9hG4bKHaBXgUjeray1m From: "ME"
> <sip:+312...@192.168.88.20>;tag=ga2cN30QDXr7j To:
> <sip:020...@sip.mycarrier.com>;tag=360313ac543ed5d93532b
> Contact: sip:02012...@77.72.xxx.xxx:5060 Call-ID:
> ed85a90e-5562-11e4-9d1c-2907737af51c CSeq: 66406142 INVITE Server:
> (Very nice Sip Registrar/Proxy Server) Allow:
> ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE Content-Type:
> application/sdp Content-Length: 204
>
> ==========
>
> The call didn't went through as it should go To:
>>>>>>> [ecallmgr_Ecallmgr-Node]=[ecallm...@testkazoo.2600hz.org

James Aimonetti

unread,
Oct 16, 2014, 4:40:50 PM10/16/14
to 2600h...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Sunny,

If stepswitch can correlate the incoming call as originating from a
known carrier doc, it will apply the formatters to the route_req
before replaying it for callflows/trunkstore/etc to process.

We also build ACLs from the gateways now, automagically adding the
found IPs to the carrier ACL returned to FreeSWITCH.

Glad you got the routing working as you needed. Thanks for sharing
your thought process as you went; it will help a lot when we move the
Global Resources wiki page into the repo's docs to know what needs
more highlighting/explanation!

James

Le 2014-10-16 13:22, Sunny Wu a écrit :
> thanks James, all clear now and it is working as instructed. Maybe
> I misunderstood the documentation
> https://2600hz.atlassian.net/wiki/display/Dedicated/Global+Resources
>
>
I read it once again and it says formatters are for incoming. As I use
> offnet document for outgoing only I maybe mislead by the samples in
> there with the formatters rules.
>
> Is it correct that the offnet document can be used for incoming
> carriers too?
>
> Cheers. Sunny
>
> Op donderdag 16 oktober 2014 21:19:50 UTC+2 schreef James
> Aimonetti:
>>
>>>> <javascript:>>;tag=ga2cN30QDXr7j To:
>>>> <sip:020...@sip.mycarrier.com <javascript:>> Contact:
>>>> sip:02012...@77.72.xxx.xxx:5060 Call-ID:
>>>> ed85a90e-5562-11e4-9d1c-2907737af51c CSeq: 66406142 INVITE
>>>> Server: (Very nice Sip Registrar/Proxy Server) Allow:
>>>> ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE
>>>> Content-Length: 0
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>>
>>>>
> recv 716 bytes from udp/[77.72.xxx.xxx]:5060 at 20:33:30.998331:
>>>> ------------------------------------------------------------------------
>>>>
>>>>
>>>>
> SIP/2.0 183 Session progress
>>>> Via: SIP/2.0/UDP
>>>> 192.168.88.20:11000;rport;branch=z9hG4bKHaBXgUjeray1m From:
>>>> "ME" <sip:+312...@192.168.88.20
>>>> <javascript:>>;tag=ga2cN30QDXr7j To:
>>>> <sip:020...@sip.mycarrier.com
>>>> <javascript:>>;tag=360313ac543ed5d93532b Contact:
>>>> sip:02012...@77.72.xxx.xxx:5060 Call-ID:
>>>> ed85a90e-5562-11e4-9d1c-2907737af51c CSeq: 66406142 INVITE
>>>> Server: (Very nice Sip Registrar/Proxy Server) Allow:
>>>> ACK,BYE,CANCEL,INVITE,REGISTER,OPTIONS,INFO,MESSAGE
>>>> Content-Type: application/sdp Content-Length: 204
>>>>
>>>> ==========
>>>>
>>>> The call didn't went through as it should go To:
>>>> <sip:0031...@sip.mycarrier.com <javascript:>> and not To:
>>>> <sip:020...@sip.mycarrier.com <javascript:>> as above.
>>>>>>>>>> [ecallmgr_Ecallmgr-Node]=[ecal...@testkazoo.2600hz.org
>>>>>>>>>>
> <javascript:>
sip:ja...@2600hz.com
tel:415.886.7905
irc:mc_ @ freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUQC1OAAoJENTKa+JPXCVgym4H/02N8Wo88U0uSiauBgfkNkAp
kfMbmucCH5jZuGJ42Ft81cAPQa5UB8mGfarPfQnMMEtWbpf8zey8HzPFamyqYfdj
VSVbUafut89WhnbnH+Jp4njxnKZU5Rt3xHDBi/oRRsS5e2VICPw/ArHWoEiCYUDr
TjAAFhGUOdVIpeZTxtV44z+mMq3USy4SxNuIhF0qfI81tGc3fJHhnRzMeOSfHPsL
NvpOZNUu2S2xs77HLbAvVNtsU908Rz2tE1cNj1qdZTmhqtr4N+e2S/JgpeYZQpNX
eI8lxq1GB5YfAxPRpzRfEaMb92I7mLsYfIqkOyyiEOf12B4RDumizucknFrA63o=
=w5ic
-----END PGP SIGNATURE-----

Sunny Wu

unread,
Oct 16, 2014, 6:08:15 PM10/16/14
to 2600h...@googlegroups.com, ja...@2600hz.com
Great if that can replace the FS gateway definitions I use now for inbound carrier with a offnet definition. I will play with that if I have some time :)

Now I have the prefix working I was just wondering why the prefix settings are not bound to the rules it self like in the french reconcile_regex in https://github.com/2600hz/kazoo/blob/master/applications/crossbar/doc/internationalization/numbers.md

Looks as prefix is bound to the gateway I can not have multiple prefix for the same gateway.

I need prefix "+31" for rule "^0(\\d+)$" and for international dialing rule "^00(\\d+)$" I need this prefix "+".
Should I make 2 different offnet docs for the same gateway now to achieve that or is there some smart ruling to do that?
 

Op donderdag 16 oktober 2014 22:40:50 UTC+2 schreef James Aimonetti:
>>>>>>>>>> [ecallmgr_Ecallmgr-Node]=[ecallm...@testkazoo.2600hz.org

Te Matau

unread,
Oct 17, 2014, 1:38:34 PM10/17/14
to 2600h...@googlegroups.com, ja...@2600hz.com
I think that dial plans may help you. These can be set at device, user and/or account. There is discussion on this group about them.
Reply all
Reply to author
Forward
0 new messages