Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

sábado, 27 de febrero de 2016

Asterisk ARI

Saltar al final de los metadatos
Ir al inicio de los metadatos

Overview

Asterisk 12 introduces the Asterisk REST Interface, a set of RESTful APIs for building Asterisk based applications. This article will walk you though getting ARI up and running.
There are three main components to building an ARI application.
The first, obviously, is the RESTful API itself. The API is documented using Swagger, a lightweight specification for documenting RESTful APIs. The Swagger API docs are used to generate validations and boilerplate in Asterisk itself, along with static wiki documentation, and interactive documentation usingSwagger-UI.
Then, Asterisk needs to send asynchronous events to the application (new channel, channel left a bridge, channel hung up, etc). This is done using a WebSocket on /ari/events. Events are sent as JSON messages, and are documented on the REST Data Models page. (See the list of subtypes for the Message data model.)
Finally, connecting the dialplan to your application is the Stasis() dialplan application. From within the dialplan, you can send a channel to Stasis(), specifying the name of the external application, along with optional arguments to pass along to the application.

miércoles, 24 de febrero de 2016

Asterisk cmd GosubIf

Asterisk cmd GosubIf

GosubIf

Conditionally jump to a particular priority, extension, or context, saving the return address.

Synopsis

  GosubIf(condition?[label1][:label2])

Asterisk 1.6 and up (?):
  GosubIf(condition?[labeliftrue[(arg1[,...][,argN])]][:labeliffalse[(arg1[,...][,argN])]])


Description


If condition is true and label1 points to a existing context|extension|priority or extension|priority or priority, then jump to that location, saving the return address. If condition is false, the same applies for label2.

Labels take the form '[context,]extension,]priority', so they can be (a) a priority, (b) an extension and a priority, or (c) a context, an extension and a priority.

Return Codes

Returns 0, or -1 if the given context, extension, or priority is invalid.

Example

exten => maincid,1,Set(CALLERID(all)=Some Company <6153824758>)
exten => maincid,2,Return
exten => faxcid,1,Set(CALLERID(all)=Some Company <6153847735>)
exten => faxcid,2,Return

; External local
exten => _9NXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9NXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External long distance
exten => _91NXXXXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _91NXXXXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External international
exten => _9011.,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9011.,n,Dial(${TRUNK}/${EXTEN:1},,T)

; New/extended syntax:
GosubIf($["${CALLERID(num)}" =~ "1234567$"]?dial-some-special,${EXTEN},1(arg1,arg2):dial-as-usually,${EXTEN},1(arg1,arg2))

Asterisk func if


Synopsis

Conditional: Returns the data following '?' if true else the data following ':'

Description

IF(<expr>?[<true>][:<false>])


Notes

  • *CLI> show function IF
  • Resides in func_logic.so module

Return value

Returns the resulting string.

Example

exten => s,1,Set(foo=${IF($[ ${x} = 7]?tval:fval)})

Another Example
exten => s,1,Set(mycid=${IF($[ ${CALLERID(num)} =102]?tval:fval)})
same=>n,Noop( value of ${mycid})


if caller id is  100 value of  ${mycid} is tval if  not is fval

Global Variables Basics

Saltar al final de los metadatos
Ir al inicio de los metadatos
Global variables are variables that don't live on one particular channel — they pertain to all calls on the system. They have global scope. There are two ways to set a global variable. The first is to declare the variable in the [globals] section of extensions.conf, like this:
[globals]
MYGLOBALVAR=somevalue
You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:
exten=>6124,1,Set(GLOBAL(MYGLOBALVAR)=somevalue)
To retrieve the value of a global channel variable, use the same syntax as you would if you were retrieving the value of a channel variable.

martes, 23 de febrero de 2016

Asterisk sip transfer

how SIP does transfers. For a blind transfer, it acts like a redirect, where the calling phone is sent a new location. But for an attended transfer, you're setting up a whole new call, then bridging the two calls. That's why it acts the way it does.

sábado, 20 de febrero de 2016

Starting Asterisk Without Scripts




Asterisk can be loaded in a variety of ways. The easiest way is to start Asterisk by running the binary file directly from the Linux command-line interface. If you are running a system that uses the init.d scripts, you can easily start and restart Asterisk that way as well. However, the preferred way of starting Asterisk is via the safe_asterisk script.

Console Commands

The Asterisk binary is, by default, located at /usr/sbin/asterisk. If you run /usr/sbin/asterisk, it will be loaded as a daemon. There are also a few switches you should be aware of that allow you to (re)connect to the Asterisk CLI, set the verbosity of CLI output, and allow core dumps if Asterisk crashes (for debugging with gdb). To explore the full range of options, run Asterisk with the -h switch:
# /usr/sbin/asterisk -h       
Here is a list of the most commonly used options:
-c
Console. This will start Asterisk as a user process (not as a server), and will connect you to the Asterisk CLI. This option is good when you are debugging your startup parameters, but should not be used for a normal system (if Asterisk is already running, this option will not work and will issue a complaint).
-v
Verbosity. This is used to set the amount of output for CLI debugging. The more “v”s, the more verbose.
-g
Core dump. If Asterisk were to crash unexpectedly, this would cause a core file to be created for later tracing with gdb. You generally do not use this in production, unless you are writing code for Asterisk and want to debug any resulting crashes.
-r
Remote. This is used to reconnect remotely to an already running Asterisk process. (The process is remote from the standpoint of the console connecting to it but is actually a local process on the machine. This has nothing to do with connecting to a remote process over a network using a protocol such as IP, as this is not supported.) This is the most common option and it is what you would use to connect to Asterisk on a system where it is running as a daemon/service that was started by init at boot time.
-x "<CLI command>"
Execute. Using this command in combination with -r allows you to execute a CLI command without having to connect to the CLI and type it manually. An example would be to send a restart, which you would do by typing asterisk -rx "reload" from the command line.
Let’s look at some examples. If you want to start Asterisk as a user program (because you are tweaking your config and will be starting and stopping it several times), and you want a verbosity level of 3, use the following command:
# /usr/sbin/asterisk -cvvv      
If the Asterisk process is already running (for example, if you have installed Asterisk as part of the init process of the system), use the reconnect switch, like so:
# /usr/sbin/asterisk -vvvr    
If you want Asterisk to dump a core file after a crash, you can use the -g switch when starting Asterisk:
# /usr/sbin/asterisk -g       
To execute a command without connecting to the CLI and typing it (perhaps for use within a script), you can use the -x switch in combination with the -r switch:
# /usr/sbin/asterisk -rx "restart now"
# /usr/sbin/asterisk -rx "database show"
# /usr/sbin/asterisk -rx "sip show peers"        
If you are experiencing crashes and would like to output to a debug file, use the following command:
# /usr/sbin/asterisk -vvvvc | tee /tmp/debug.log     
Note that you do not have to use the v switch if you do not want the system to provide detailed output of what is going on. On a busy system, you may not want to get any output, as it can interfere with whatever you are doing on the console.

viernes, 19 de febrero de 2016

Asterisk acl.conf

/etc/asterisk/sip.conf
[general]
contactacl=example_named_acl1

or on  specifiy sip peer

[102]
contactacl=example_named_acl1




/etc/asterisk/acl.conf

[example_named_acl1]
deny=0.0.0.0/0.0.0.0
permit=209.16.236.0
permit=209.16.236.1

sábado, 13 de febrero de 2016

Setting PJSIP device extension




[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5065
local_net=192.168.0.0/8
external_media_address=198.51.100.5
external_signaling_address=198.51.100.5

[6001]
type=endpoint
context=internal
disallow=all
allow=ulaw
auth=6001
aors=6001
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes  ; necessary if endpoint does not know/register public ip:port
ice_support=yes   ;This is specific to clients that support NAT traversal
send_pai=yes
transport=transport-udp

[6001]
type=auth
auth_type=userpass
password=19111@@!
username=6001

[6001]
type=aor
max_contacts= 2
qualify_frequency=1    ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200        ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000  ; Minimum keep alive time for an AoR (default: "60")




trunk

[400]
type=endpoint
context=from-external
disallow=all
allow=ulaw
auth=400
aors=400
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes  ; necessary if endpoint does not know/register public ip:port
ice_support=yes   ;This is specific to clients that support NAT traversal
rewrite_contact=yes
send_pai=yes
transport=transport-udp

                   ;for a deeper explanation of this topic.
[400]
type=auth
auth_type=userpass
password=193011
username=400

[400]
type=aor
max_contacts= 1
qualify_frequency=10    ; Interval at which to qualify an AoR (default: "0")
authenticate_qualify=no
remove_existing=yes
maximum_expiration=7200        ; Maximum time to keep an AoR (default: "7200")
minimum_expiration=6000  ; Minimum keep alive time for an AoR (default: "60")



[twilio]
type=aor
contact=sip:asteriskpjsip.pstn.us1.twilio.com:5060
qualify_frequency=100

[twilio]
type=endpoint
context=from-external
disallow=all
allow=ulaw
aors=twilio
transport=transport-udp-trunk
send_diversion=yes     ; Send the Diversion header conveying the diversion
                        ; information to the called user agent (default: "yes")
send_pai=yes    ; Send the P Asserted Identity header (default: "no")
send_rpid=yes
trust_id_inbound=yes   ; Accept identification information received from this
                        ; endpoint (default: "no")
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes  ; necessary if endpoint does not know/register public ip:port
[twilio]
type=identify
endpoint=twilio
match=54.172.60.0/8
match=68.183.142.204

[rapidvox]
type=endpoint
context=from-external
disallow=all
allow=ulaw
outbound_auth=rapidvox
aors=rapidvox
transport=transport-udp-trunk
from_user=ambiorixg12
send_diversion=yes     ; Send the Diversion header conveying the diversion
                        ; information to the called user agent (default: "yes")
send_pai=yes    ; Send the P Asserted Identity header (default: "no")
send_rpid=yes
trust_id_inbound=yes   ; Accept identification information received from this
                        ; endpoint (default: "no")
trust_id_outbound=yes



[rapidvox]
type=aor
contact=sip:sip.rapidvox.com:5060
qualify_frequency=200

[rapidvox]
type=auth
auth_type=userpass
username=ambiorixg12
password=terezx

[rapidvox]
type=identify
endpoint=rapidvox
match=sip.rapidvox.com

---
[telnyx]
type=aor
contact=sip:sip.telnyx.com:5060
qualify_frequency=100

[telnyx]
type=endpoint
context=ctx-app-incoming
disallow=all
allow=ulaw
aors=telnyx
transport=transport-udp
send_diversion=yes     ; Send the Diversion header conveying the diversion
                        ; information to the called user agent (default: "yes")
send_pai=yes    ; Send the P Asserted Identity header (default: "no")
send_rpid=yes
trust_id_inbound=yes   ; Accept identification information received from this
                        ; endpoint (default: "no")
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes  ; necessary if endpoint does not know/register public ip:port

[telnyx]
type=identify
endpoint=telnyx
match=192.76.120.10
match=64.16.250.10
----

;;anoymous calls

;;anonymous

[transport-udp-anonymous]
type=transport
protocol=udp
bind=0.0.0.0:5067


[anonymous]
type=endpoint
context=from-anonymous
disallow=all
allow=ulaw
transport=transport-udp-anonymous




https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip

https://wiki.asterisk.org/wiki/display/AST/PJSIP+Configuration+Sections+and+Relationships

https://wiki.asterisk.org/wiki/display/AST/Endpoints+and+Location%2C+A+Match+Made+in+Heaven
https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip

https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples

https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Configuration_res_pjsip#Asterisk16Configuration_res_pjsip-contact_qualify_frequency

jueves, 11 de febrero de 2016

FreePNX elastix duplicate key error adding trunks

FATAL ERROR
DB Error: already exists
INSERT INTO sip (id, keyword, data, flags) values ('tr-peer-3',?,?,'0')



find the   DB PASS and user on  /etc/amporta.conf



AMPDBUSER=asteriskuser

AMPDBPASS=mypass


mysql -user asteriskuser -pmypass  asterisk

FIX

mysql> delete from sip where id='tr-peer-3';