freeswitch ws php,freeswitch的安装和配置

该博客详细介绍了FreeSwitch的安装步骤,包括基础包、依赖包、代码依赖包的安装,以及编译、配置、错误解决等过程。此外,还涉及到拨号计划、CDR配置、端口设置等内容,适合需要搭建FreeSwitch服务器的读者参考。
摘要由CSDN通过智能技术生成

目录

1. 安装freeswitch

1.1 相关地址

1.2 安装基础包

$ sudo yum install epel-release vim -y

$ curl -O http://files.freeswitch.org/freeswitch-releases/freeswitch-1.6.6.tar.bz2

$ sudo yum install bzip2 -y

$ tar xvjf freeswitch-1.6.6.tar.bz2

1.3 安装依赖包

$ sudo yum install gcc-c++ sqlite-devel zlib-devel libcurl-devel pcre-devel speex-devel ldns-devel libedit-devel openssl-devel -y

$ sudo yum install libjpeg-devel lua-devel libsndfile-devel libyuv-devel git libtool -y

1.4 代码依赖包

$ cd freeswitch-1.6.6

$ cd libs/

$ git clone https://freeswitch.org/stash/scm/sd/libyuv.git

$ cd libyuv/

$ make -f linux.mk CXXFLAGS="-fPIC -O2 -fomit-frame-pointer -Iinclude/"

$ sudo make install

$ sudo cp /usr/lib/pkgconfig/libyuv.pc /usr/lib64/pkgconfig/

$ cd ..

$ git clone https://freeswitch.org/stash/scm/sd/libvpx.git

$ cd libvpx/

$ sudo yum install yasm -y

$ ./configure --enable-pic --disable-static --enable-shared

$ make

$ sudo make install

$ sudo cp /usr/local/lib/pkgconfig/vpx.pc /usr/lib64/pkgconfig/

$ cd ..

$ git clone https://freeswitch.org/stash/scm/sd/opus.git

$ cd opus/

$ ./autogen.sh

$ ./configure

$ make

$ sudo make install

$ sudo cp /usr/local/lib/pkgconfig/opus.pc /usr/lib64/pkgconfig

$ cd ..

$ git clone https://freeswitch.org/stash/scm/sd/libpng.git

$ cd libpng/

$ ./configure

$ make

$ sudo make install

$ sudo cp /usr/local/lib/pkgconfig/libpng* /usr/lib64/pkgconfig/

1.5 编译

$ cd freeswitch-1.6.6

$ ./configure

$ make

$ sudo make install

1.6 安装声音文件

$ sudo make cd-sounds-install

$ sudo make cd-moh-install

1.7 新版本安装 上面的安装依赖包不用git到工程文件夹

$ git clone https://freeswitch.org/stash/scm/fs/freeswitch.git

$ cd freeswitch

$ sh support-d/prereq.sh

$ sh bootstrap.sh

$ ./configure --prefix=/usr/local/freeswitch

$ make

$ sudo make install

1.8 设置链接符号,便于使用

$ sudo ln -sf /usr/local/freeswitch/bin/freeswitch /usr/local/bin/

$ sudo ln -sf /usr/local/freeswitch/bin/fs_cli /usr/local/bin/

1.9 部署成服务

sudo vim /usr/lib/systemd/system/freeswitch.service

[Unit]

Description=freeswitch

After=syslog.target

After=network.target

[Service]

Type=simple

User=root

Group=root

WorkingDirectory=/home/mintcode

ExecStart=/usr/local/freeswitch/bin/freeswitch

ExecStop=/usr/local/freeswitch/bin/freeswitch -stop

Restart=always

[Install]

WantedBy=multi-user.target

1.10 配置文件

conf\sip_profiles\internal.xml 配置sip信息

1.10.1 添加H263~H2641.7版本

$ sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/modules.conf.xml的去掉注释

$ sudo vim /usr/local/freeswitch/etc/freeswitch/vars.xml

1.10.2 添加授权注册 需要编译mod_xml_curl

$ sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/modules.conf.xml的去掉注释

$ sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/xml_curl.conf.xml

MSB配置

/>

{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}

decodeURIComponent(request.headers.get('user'))

]]>

text/xml

1.11 相关命令

显示哪些用户已注册 sofia status profile internal reg

控制台显示info级别日志 fs_cli -l info

2. 错误解决

2.1 freeswitch.service start request repeated too quickly, refusing to start

#去掉下面的配置项

WorkingDirectory=/home/mintcode

2.2 fs_cli连接不上

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/event_socket.conf.xml

2.3 2016-03-08 14:29:50.925294 [ERR] mod_xml_curl.c:459 Binding has no url!

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/xml_curl.conf.xml

2.4. 呼叫慢

sudo vim /usr/local/freeswitch/etc/freeswitch/dialplan/default.xml

2.5 重启后 failure to connect to CORE_DB

rm /usr/local/freeswitch/var/lib/freeswitch/db/core.db

3. 拨号计划

3.1 相关文档

通话记录地址/usr/local/freeswitch/var/log/freeswitch/cdr-csv/Master.csv

3.2 安装mod_curl和mod_flite

3.2.1 配置modules.conf

sudo vim /home/mintcode/freeswitch/modules.conf

applications/mod_curl

asr_tts/mod_flite

3.2.2 安装libflite-devel

$ cd libs/

$ git clone https://freeswitch.org/stash/scm/sd/libflite.git

$ cd libflite/

$ ./configure --enable-pic --disable-static --enable-shared && make

$ sudo make install

$ sudo cp /usr/local/lib/pkgconfig/flite.pc /usr/lib64/pkgconfig

3.2.3 重新编译

$ cd /home/mintcode/freeswitch

$ ./configure --prefix=/usr/local/freeswitch

$ make

$ sudo make install

3.2.4 配置modules.conf.xml

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/modules.conf.xml

3.3 构建拨号计划00_fsm.xml

sudo vim /usr/local/freeswitch/etc/freeswitch/dialplan/public/00_fsm.xml

continue默认把它设置为false,设为true表示FS在当前分机号的所有action都解析成功是否继续。

break表示判断后的行为,有以下值:

On-true:第一次匹配后停止查找

On-false:默认值,第一次失败后停止查找

Always:不管匹配与否都停止

Never: 无论匹配与否都继续查找

-->

3.3.1 MSB配置

/>

fs:${header.routerId}

var result={ 'appName': 'launchr', 'appToken':'verify-code' }; request.body.split('&').forEach(function(a){var

key=a.split('=');result[key[0]]=key[1]}); result.case=result.case||'USER_NOT_REGISTERED';

result.userName=result.caller_id_name; result.to=[result.destination_number];

request.body=JSON.stringify(result);

/>

application/json

POST

3.4 拨号计划参数

变量名称

描述

caller_id_name

呼叫方的名称

destination_number

呼叫方所拨打的号码

direction

当前呼叫段是入站inbound或出站outbound

channel_name

此调用的入站通道的名称,例如:sofia/sales/John_Smith@192.168.1.1

状态,例如CS_EXECUTE或CS_HANGUP

呼叫结束原因,例如NO_ANSWER或NORMAL_CLEARING、USER_BUSY

last_bridge_hangup_cause

最后呼叫结束的原因

动作

描述

answer

应答呼叫

bridge

桥叫到另一会话

log

日志文件中写入一条消息

hangup

断开呼叫

playback

播放音频文件或音流

set

通道设置变量

transfer

转移呼叫到另一个会话

3.5 拨号记录CDR

3.5.1.1 配置modules.conf

sudo vim /home/mintcode/freeswitch/modules.conf

event_handlers/mod_cdr_sql

event_handlers/mod_json_cdr

3.5.1.2 编译安装

$ sudo yum install unixODBC mysql-connector-odbc -y

$ sudo make mod_odbc_cdr

$ sudo make mod_odbc_cdr-install

$ sudo cp /home/mintcode/freeswitch/src/mod/event_handlers/mod_odbc_cdr/conf/autoload_configs/odbc_cdr.conf.xml /usr/local/freeswitch/etc/freeswitch/autoload_configs/.

$ sudo make mod_json_cdr

$ sudo make mod_json_cdr-install

$ sudo cp /home/mintcode/freeswitch/src/mod/event_handlers/mod_json_cdr/conf/autoload_configs/json_cdr.conf.xml /usr/local/freeswitch/etc/freeswitch/autoload_configs/.

3.5.1.3 配置modules.conf.xml

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/modules.conf.xml

3.5.1.4 配置odbc_cdr.conf.xml

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/odbc_cdr.conf.xml

sudo vim /usr/local/freeswitch/etc/freeswitch/autoload_configs/json_cdr.conf.xml

3.5.1.5 生成表

CREATE TABLE cdr_table_a_leg (

CallId varchar(50) DEFAULT NULL,

orig_id varchar(50) DEFAULT NULL,

term_id varchar(50) DEFAULT NULL,

ClientId varchar(50) DEFAULT NULL,

IP varchar(50) DEFAULT NULL,

IPInternal varchar(50) DEFAULT NULL,

CODEC varchar(50) DEFAULT NULL,

directGateway varchar(50) DEFAULT NULL,

redirectGateway varchar(50) DEFAULT NULL,

CallerID varchar(50) DEFAULT NULL,

TelNumber varchar(50) DEFAULT NULL,

TelNumberFull varchar(50) DEFAULT NULL,

sip_endpoint_disposition varchar(50) DEFAULT NULL,

sip_current_application varchar(50) DEFAULT NULL

);

CREATE TABLE cdr_table_b_leg (

CallId varchar(50) DEFAULT NULL,

orig_id varchar(50) DEFAULT NULL,

term_id varchar(50) DEFAULT NULL,

ClientId varchar(50) DEFAULT NULL,

IP varchar(50) DEFAULT NULL,

IPInternal varchar(50) DEFAULT NULL,

CODEC varchar(50) DEFAULT NULL,

directGateway varchar(50) DEFAULT NULL,

redirectGateway varchar(50) DEFAULT NULL,

CallerID varchar(50) DEFAULT NULL,

TelNumber varchar(50) DEFAULT NULL,

TelNumberFull varchar(50) DEFAULT NULL,

sip_endpoint_disposition varchar(50) DEFAULT NULL,

sip_current_application varchar(50) DEFAULT NULL

);

CREATE TABLE cdr_table_both (

CallId varchar(50) DEFAULT NULL,

orig_id varchar(50) DEFAULT NULL,

TEST_id varchar(50) DEFAULT NULL

);

4. 配置wss实现webrtc

5. freeswitch端口

5.1 基本端口

FireWall Ports Network Protocol Application Protocol Description

1719 UDP H.323 Gatekeeper RAS port

1720 TCP H.323 Call Signaling

3478 UDP STUN service Used for NAT traversal

3479 UDP STUN service Used for NAT traversal

5002 TCP MLP protocol server

5003 UDP Neighborhood service

5060 UDP & TCP SIP UAS Used for SIP signaling (Standard SIP Port, for default Internal Profile)

5070 UDP & TCP SIP UAS Used for SIP signaling (For default "NAT" Profile)

5080 UDP & TCP SIP UAS Used for SIP signaling (For default "External" Profile)

8021 TCP ESL Used for mod_event_socket *

16384-32768 UDP RTP/ RTCP multimedia streaming Used for audio/video data in SIP and other protocols

5066 TCP Websocket Used for WebRTC

7443 TCP Websocket Used for WebRTC

5.2 rtp端口范围

conf/autoload_configs/switch.conf.xml

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值