Soporte & Consultoria

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

martes, 2 de junio de 2020

Failed, Invalid session

fwconsole unlock seugies5nmh1973hrvrc4fmfb3


Unlocking: seugies5nmh1973hrvrc4fmfb3 Failed, Invalid session


FIX

[root@A2Billing ~]# echo ' session.save_path = "/var/lib/php/session"'> /etc/php.d/freepbx.ini


[root@A2Billing ~]# service httpd restrt

martes, 12 de mayo de 2020

HOW TO USE AN ASTERISK CALLFILE

Articles


How to use an Asterisk Callfile

Asterisk call files are structured files which that tell asterisk how to initiate a call when when moved to the appropriate directory. you can use them in order to initei calls without an extension or bypass the dialplan for troubleshooting purposes. 

Requirements and general information on how it works 

  • pbx_spool.so module needs to be loaded into asterisk
  • Calls files will only be readed when they are moved into astspooldir directory defined in asterisk.conf (usually /var/spool/asterisk/outgoing/)
  • Upon detection Asterisk will immediately execute the directives unless the modification time is in the future, in which asterisk will wait for the time to on the server to match before placing executing. 
  • Upon completion asterisk will remove the call from spooling directory 

Syntax 

  • ​Specify where and how to call
    • Channel: <channel>: Channel to use for the call.
    • CallerID: "name" <number> Caller ID, Please note: It may not work if you do not respect the format: CallerID: "Some Name" <1234>
    • MaxRetries: <number> Number of retries before failing (not including the initial attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
    • RetryTime: <number> Seconds between retries, Don't hammer an unavailable phone. Default is 300 (5 min).
    • WaitTime: <number> Seconds to wait for an answer. Default is 45.
    • Account: Set the account code to use.
  • If the call answers, connect it here:
    • Context: <context-name> Context in extensions.conf
    • Extension: <ext> Extension definition in extensions.conf
    • Priority: <priority> Priority of extension to start with
    • Set: Set a variable for use in the extension logic (example: file1=/tmp/to )
    • Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
    • Data: The options to be passed to application
  • Other parameters 
    • AlwaysDelete: Yes/No - If the file's modification time is in the future, the call file will not be deleted
    • Archive: Yes/No - Move to subdir "outgoing_done" with "Status: value", where value can be Completed, Expired or Failed.

Examples

playback.call

channel: DAHDI/1/123456789
application: Playback
data: Demo-congrats
 
SendFax.call
 
channel: SIP/PROVIDER/1234567890
application: SendFax
data: fax.tiff
setvar=FAXID=1430402112
setvar=FAXOPT(ecm)=yes
setvar=FAXOPT(minrate)=2400
setvar=FAXOPT(maxrate)=14400

How to initiate a call file

  1. Create a callfile using
  2. Set file permissions with chmod 777 <filename>
  3. Move the file to the proper spool directory with #cp -ap /root/callfile /tmp/cf && mv /tmp/cf /var/spool/asterisk/outgoing/
Note: it's not recommended to copy the file to the spool directory because asterisk could start reading the file before the operating system stop writing it causing a failure. 

domingo, 3 de mayo de 2020

Asterisk Uninstall




 +--------- Asterisk Uninstall Complete -----+
 + Asterisk binaries, sounds, man pages,     +
 + headers, modules, and firmware builds,    +
 + have all been uninstalled.                +
 +                                           +
 + To remove ALL traces of Asterisk,         +
 + including configuration, spool            +
 + directories, and logs, run the following  +
 + command:                                  +
 +                                           +
 +             make uninstall-all

martes, 28 de abril de 2020

QUEUE POST curl

[subCreateTicket]
exten=>s,1,Wait(1)
same=>n,Noop( sending post with data : ${MEMBERINTERFACE} ${CRM_SOURCE} )
same=>n,Set(tikcket=${SHELL(php /var/www/html/queue_post.php ${MEMBERINTERFACE} ${CRM_SOURCE})} )
same =>n,Return()
------------------
<?php
//$agent_exten="Local/633@from-queue/n";
$agent_exten=$argv[1];
$cid=$argv[2];
$agent_exten=stristr($agent_exten, '@', true);
$agent_exten=stristr($agent_exten, '/');
$agent_exten= str_replace('/', '', $agent_exten);
echo $post=shell_exec("curl -d \"ext=$agent_exten&cid=$cid&?key=dHhMZkN2I1t\" \"https://api.com\" ");
?>

jueves, 23 de abril de 2020

Asterisk Realtime Centos 7






Asterisk realtime centos 7

yum install epel-release

Install dependencies

yum install unixODBC-devel

yum install unixODBC

yum install python-devel

yum install python-pip

yum install MySQL-python

yum install mysql-connector-odbc

yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel




Install LAMP
https://hostadvice.com/how-to/how-to-install-lamp-stack-on-centos-7/

Install Asterisk


sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
reboot
MAKE SURE SELINUX IS DISABLED running the next command
sestatus
yum -y update
yum -y groupinstall core base "Development Tools"
yum install -y make wget openssl-devel ncurses-devel newt-devel libxml2-devel kernel-devel gcc gcc-c++ sqlite-devel
cd /usr/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
tar zxvf asterisk*
cd /usr/src/asterisk*
contrib/scripts/install_prereq install

./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-jansson-bundled && make menuselect && make && make install
make samples
make config
ldconfig
service asterisk start
asterisk -rvvvvvvvvvvvvv

Install Realtime 

Create the DB

# mysqladmin -u root -p create asterisk

First, install Alembic:
# pip install alembic
Then, move to the Asterisk source directory containing the Alembic scripts:
# cd contrib/ast-db-manage/
Next, edit the config.ini.sample file and change the sqlalchemy.url option, e.g.
sqlalchemy.url = mysql://root:password@localhost/asterisk
such that the URL matches the username and password required to access your database.
Then rename the config.ini.sample file to config.ini
# cp config.ini.sample config.ini
Finally, use Alembic to setup the database tables:
# alembic -c config.ini upgrade head
You'll see something similar to:
# alembic -c config.ini upgrade head
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.migration] Running upgrade None -> 4da0c5f79a9c, Create tables
INFO  [alembic.migration] Running upgrade 4da0c5f79a9c -> 43956d550a44, Add tables for pjsip
#
You can then connect to MySQL to see that the tables were created:
# mysql -u root -p -D asterisk

mysql> show tables;
+--------------------+
| Tables_in_asterisk |
+--------------------+
| alembic_version    |
| iaxfriends         |
| meetme             |
| musiconhold        |
| ps_aors            |
| ps_auths           |
| ps_contacts        |
| ps_domain_aliases  |
| ps_endpoint_id_ips |
| ps_endpoints       |
| sippeers           |
| voicemail          |
+--------------------+
12 rows in set (0.00 sec)
mysql> quit



/etc/odbc.ini
[asterisk-mysql]
Description = MySQL connection to 'asterisk' database
Driver = MySQL
Database = asterisk
Server = localhost
UserName = root
Password = 7891
Port = 3306
Socket = /var/lib/mysql/mysql.sock
/etc/odbcinst.ini
# Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/psqlodbc.so
Setup = /usr/lib/libodbcpsqlS.so
Driver64 = /usr/lib64/psqlodbc.so
Setup64 = /usr/lib64/libodbcpsqlS.so
FileUsage = 1
# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
/etc/asterisk/res_odbc.conf
[asterisk-mysql]
enabled => yes
dsn => asterisk-mysql
username => root
password => 7891
pre-connect => yes
/etc/asterisk/cdr_adaptive_odbc.conf
[asterisk-mysql]
connection=asterisk-mysql
table=cdr
alias start => calldate
----------------------------
Load on asterisk
module reload res_odbc.so

Check connection

asterisk_realtime*CLI> odbc show all

ODBC DSN Settings
-----------------

  Name:   asterisk
  DSN:    asterisk
    Number of active connections: 1 (out of 1)
    Logging: Disabled



Connecting PJSIP Sorcery to the Realtime Database


nano  /etc/asterisk/sorcery.conf

[res_pjsip] ; Realtime PJSIP configuration wizard
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts

[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips

Realtime Configuration

/etc/asterisk/extconfig.conf
ps_endpoints => odbc,asterisk
ps_auths => odbc,asterisk
ps_aors => odbc,asterisk
ps_domain_aliases => odbc,asterisk
ps_endpoint_id_ips => odbc,asterisk
ps_contacts => odbc,asterisk


/etc/asterisk/modules.conf
preload => res_odbc.so
preload => res_config_odbc.so
noload => chan_sip.so 


/etc/asterisk/pjsip.conf
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

Create endpoints

insert into ps_aors (id, max_contacts) values (103, 1); insert into ps_auths (id, auth_type, password, username) values (103, 'userpass', 103, 103); insert into ps_endpoints (id, transport, aors, auth, context, disallow, allow, direct_media) values (103, 'transport-udp', '103', '103', 'testing', 'all', 'g722', 'no');

                      pjsip show endpoint 103

https://gist.github.com/ambiorixg12/8cea6702d8c2b5afef31690c0f5d72e0

https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime



----------------------------php code----
php /home/ambiorix/insert_device.php 2222

<?php
$link = mysqli_connect("localhost", "root", "mypass", "asterisk");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$sip_device ="$argv[1]";

$query1 = "INSERT INTO `ps_aors` (`id`, `max_contacts`) VALUES ($sip_device, 1)";
if (mysqli_query($link, $query1)) {
    printf("Query 1 executed successfully.\n");
} else {
    printf("Error executing query 1: %s\n", mysqli_error($link));
}

$query2 = "INSERT INTO `ps_auths` (`id`, `auth_type`, `password`, `username`) VALUES ($sip_device, 'userpass', $sip_device, $sip_device)";
if (mysqli_query($link, $query2)) {
    printf("Query 2 executed successfully.\n");
} else {
    printf("Error executing query 2: %s\n", mysqli_error($link));
}

$query3 = "INSERT INTO `ps_endpoints` (`id`, `transport`, `aors`, `auth`, `context`, `disallow`, `allow`, `direct_media`) 
VALUES ($sip_device, 'transport-udp', '$sip_device', '$sip_device', 'testing', 'all', 'g722', 'no')";
if (mysqli_query($link, $query3)) {
    printf("Query 3 executed successfully.\n");
} else {
    printf("Error executing query 3: %s\n", mysqli_error($link));
}

/* close connection */
mysqli_close($link);
?>