/sip-app

基于 sip-servlet 开发的通信应用服务器(跨服务器呼叫部分)

Primary LanguageJava

融合通信 sip-servlet

主要功能点为 跨域呼叫,使用 XMS 作为媒体服务器,并提供一定的网络丢包容错能力

跨域呼叫:两个不同 SIP 服务器的用户可以互相通话

所需安装文件

  • Linux 镜像
    • CentOS-7-x86_64-DVD-1511.iso
    • PowerMedia-3.3.16104-1.c7.x86_64.iso
  • 安装包
    • lrzsz-0.12.20-36.el7.x86_64.rpm
    • mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz
    • jdk-7u79-linux-x64.rpm
    • xmlstarlet-1.5.0-1.el6.rf.x86_64.rpm
    • ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
    • libevent-2.0.22-stable.tar.gz
    • mss-3.1.633-jboss-as-7.2.0.Final.zip
  • 配置文件
    • change-ip-sip-servlet.sh
    • dlgc_demos.properties
    • dlgc_JSR309.properties

最后三个配置文件在项目的 env 文件夹中

部署过程

Linux

  • sip-servlet
    • CentOS 7.2 (CentOS-7-x86_64-DVD-1511.iso)
    • GNOME Desktop(Compatibility Libraries & Development Tools)
  • XMS
    • 3.3.16104.rc1

安装 lrzsz 后可以使用 rz 命令进行文件上传

rpm -ivh lrzsz-0.12.20-36.el7.x86_64.rpm

关闭并禁用防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

MySql 5.6

rpm -qa | grep mariadb
rpm -e --nodeps xxx
rm /etc/my.cnf
groupadd mysql
useradd -g mysql mysql

mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz 放在 /usr/local

tar -zxvf mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz
mv mysql<tab> mysql
vim /etc/my.cnf
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock

[mysqld]
character-set-server=utf8
skip-name-resolve
lower_case_table_names=1
port = 3306
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M

[client]
default-character-set=utf8
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R mysql:mysql data
chown 777 /etc/my.cnf
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
service mysqld start
vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
mysql -u root -p
use mysql;
update user set password=password('123456') where user='root'and host='localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;

安装完成后的 mysql 用户名和密码分别是 root 和 123456

JDK 1.7

移除自带的 java 相关的组件(如果是最小化安装的话这一步不用做)

rpm -qa | grep java
rpm -e --nodeps 所有上面列出的条目,空格分隔

安装 jdk

rpm -ivh jdk-7u79-linux-x64.rpm

配置环境变量

vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile

验证

java -version
javac

xmlstarlet、Tmux (可选)

rpm -ivh xmlstarlet-1.5.0-1.el6.rf.x86_64.rpm
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
tar -xvzf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local && make && make install
cd ..
tar -xvzf tmux-2.1.tar.gz
cd tmux-2.1
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local
make && make install

JBoss & SipServlet

mss-3.1.633-jboss-as-7.2.0.Final.zip 放在 /root 下并解压

unzip mss-3.1.633-jboss-as-7.2.0.Final.zip

将脚本 change-ip-sip-servlet.sh 放在 mss 目录下,赋予执行权限后执行脚本

chmod 777 change-ip-sip-servlet.sh
./change-ip-sip-servlet.sh

新建 env 文件夹,用于放置配置文件

mkdir env && cd env

配置文件 sysstr.env

echo "realm 10.109.246.93" > sysstr.env

配置文件 jdbc.properties

vim jdbc.properties
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.109.246.143:3306/my_sip_app_test
jdbc.userName=zlren
jdbc.password=Lab2016!

配置文件 heart.properties

vim heart.properties
enable=1
cycle=10
timeout=15
check=15
ip=10.109.246.93
cd /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/
java -cp ../../modules/system/layers/base/org/picketbox/main/picketbox-4.0.15.Final.jar org.jboss.security.auth.callback.RFC2617Digest admin sip-servlets secret
echo "admin=<hash>" > sip-servlets-users.properties

configuration 下,生成证书

cd /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/
mkdir ca && cd ca
keytool -genkeypair -alias myserver -keyalg RSA -keysize 1024 -keypass secret -validity 365 -storetype jks -keystore myserver.jks -storepass secret -v -dname "CN=James Smith, OU=Engineering, O=My Company, L=My City, S=My State, C=US"

修改启动脚本

vim /root/mss-3.1.633-jboss-as-7.2.0.Final/bin/run.sh

在上面文件的最后增加以下内容,以后我们会用 run.sh 作为启动脚本

./standalone.sh -Djavax.net.ssl.keyStorePassword=secret -Dgov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE=Disabled -Djavax.net.ssl.keyStore=/root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/ca/myserver.jks -Djavax.net.ssl.trustStorePassword=secret -Djavax.net.ssl.trustStore=/root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/ca/myserver.jks

配置 httpswss5083

vim /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/standalone-sip.xml

搜索 urn:jboss:domain:web:1.4 ,注释的那一段后面

<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl protocol="TLSv1,TLSv1.1,TLSv1.2" certificate-key-file="/root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/ca/myserver.jks" certificate-file="/root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/ca/myserver.jks" password="secret"/>
</connector>

下面这两句添加到类似位置

<connector name="sip-wss" protocol="SIP/2.0" scheme="sip" socket-binding="sip-wss"/>
<socket-binding name="sip-wss" port="5083"/>

部署 war

cd /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/deployments/
rm -rf *
放入 war 包

修改 dar 文件

vim /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/dars/mobicents-dar.properties
REGISTER: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
INVITE: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
INFO: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
MESSAGE: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
# RESPONSE: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet","DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
ALL: ("com.zczg.app.SipAppP2PApplication","DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
# CANCEL: ("com.zczg.app.SipAppP2PApplication.SipAppP2PServlet","DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")

XMS

修改配置文件

vim /root/mss-3.1.633-jboss-as-7.2.0.Final/bin/standalone.sh

export JBOSS_HOME 的后面添加

# Dialogic additions
export APPSERVER_PLATFORM="TELESTAX"
export DIALOGIC_DEMO_PROPERTY_FILE=${JBOSS_HOME}/standalone/configuration/dlgc_demos.properties
export DLG_PROPERTY_FILE=${JBOSS_HOME}/standalone/configuration/dlgc_JSR309.properties

dlgc_demos.propertiesdlgc_JSR309.properties 放在 configuration

vim /root/mss-3.1.633-jboss-as-7.2.0.Final/standalone/configuration/dlgc_JSR309.properties
connector.sip.address=${SipServerIP}
connector.sip.port=5080
mediaserver.1.sip.address=${XmsIP}
mediaserver.1.sip.port=5060

启动

启动前保证 mysql 服务器已经启动,因为 sip-servlet 需要从数据库中读取域信息

手动启动

写个脚本:start_sip_servlet.sh,内容如下(添加执行权限 +x)

cd /root/mss-3.1.633-jboss-as-7.2.0.Final/bin
./run.sh

开机自启动

/root/mss-3.1.633-jboss-as-7.2.0.Final/bin/run.sh 添加到以下文件的末尾处,完成后赋予执行权限

vim /etc/rc.d/rc.local

chmod +x /etc/rc.d/rc.local

附:macOS 以忽略证书错误的形式启动 Chrome

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --ignore-certificate-errors