FreeSwitch的版本历程
2006年-第一个版本
2008年-1.0凤凰版
2012年-Freeswitch 1.2
2014年-FreeSwitch 1.4 WebRTC
2015年-FreeSwitch 1.6 视频通话和视频会议
2017年-FreeSwitch 1.8
2019年-FreeSwitch 1.10
2020年-FreeSwitch 1.10.3
FreeSwitch的安装
从github仓库上下载freeswitch
# git clone https://github.com/signalwire/freeswitch.git
# cd freeswitch
# git checkout -b v1.10 remotes/origin/v1.10
# ./bootstrap.sh
# ./configure
# make
# make install
在执行 ./configure 的时候提示缺少如下库
please install spandsp3 devel package or equivalent
# git clone https://github.com/freeswitch/spandsp.git
# cd spandsp
# ./bootstrap.sh -j
# ./configure
# make
# make install
# ldconfig
checking for sofia-sip-ua >= 1.13.3... configure: error: no usable sofia-sip; please install
sofia-sip-ua devel package or equivalent
# git clone https://github.com/freeswitch/sofia-sip.gitcd sofia-sip
# ./bootstrap.sh -j
# ./configure
# make
# make install
# ldconfig
----------------以下错误出现在Ubuntu 18.04 系统上,未出现在Ubuntu 20.4 系统上--------------
You must install libks to build mod_signalwire. Stop.
# apt-get install uuid-dev
# git clone https://github.com/signalwire/libks.git
# cd libks
# cmake .
# make
# make install
You must install signalwire-client-c to build mod_signalwire. Stop.
# git clone https://github.com/signalwire/signalwire-c.git
# cd signalwire-c
# cmake .
# make
# make install
FreeSwitch的使用
1、freeswitch配置文件中常用项
修改配置文件 /usr/local/freeswitch/conf/vars.xml
因为freeswitch很多安装在NAT网络环境中,需要设置extern_rtp_ip和external_sip_ip
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=stun:stun.freeswitch.org"/>
<X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.freeswitch.org"/>
修改配置文件 /usr/local/freeswitch/conf/sip_profiles/internal.xml
因为freeswitch很多安装在NAT网络环境中,需要设置
<param name="aggressive-nat-detection" value="true"/> 取消注释开启
<param name="ext-rtp-ip" value="auto-nat"/> 设置相应stun地址
<param name="ext-sip-ip" value="auto-nat"/> 设置相应stun地址
<param name="NDLB-force-rport" value="true"/> 取消注释开启
<param name="inbound-proxy-media" value="true"/> 取消对应注释开启proxy模式
<!-- for sip over websocket support -->
<param name="ws-binding" value=":5066"/> 开启WS
<!-- for sip over secure websocket support -->
<!-- You need wss.pem in $${certs_dir} for wss or one will be created for you -->
<!--<param name="wss-binding" value=":7443"/>--> 开启WSS,取消注释,需导入WSS.PEM证书
修改配置文件 /usr/local/freeswitch/conf/autoload_configs/switch.conf.xml
<param name="rtp-start-port" value="16384"/> 设置RTP port使用范围
<param name="rtp-end-port" value="32768"/>
2、freeswitch常用命令
# /usr/local/freeswitch/bin/freeswitch 启动并前台运行
# /usr/local/freeswitch/bin/freeswitch -nc 启动并后台运行
# /usr/local/freeswitch/bin/freeswitch -stop 停止
3、运行fs_cli,连接调试终端,打印服务器DEBUG信息
# /usr/local/freeswitch/bin/fs_cli -H 127.0.0.1
FreeSwitch调试终端交互如下:
freeswitch@iZuf6fya4> reloadxml 重新加载配置信息
freeswitch@iZuf6fya4> stun xxx.xxx.xxx.xxx 测试STUN服务器
freeswitch@iZuf6fya4> sofia status profile internal reg 显示在线注册用户信息
freeswitch@iZuf6fya4> sofia status profile external 查看external配置信息
freeswitch@iZuf6fya4> originate user/1000 &echo 使用originate向注册用户1000发起呼叫
freeswitch@iZuf6fya4> sofia global siptrace on 开启sip消息显示
freeswitch@iZuf6fya4> sofia global siptrace off 关闭sip消息显示
freeswitch@iZuf6fya4> /exit, /bye, /quit Ctrl+D 退出客户端
FressSwitch会议配置
freeswitch@iZuf6fya4> conference 3000 dial user/1001 呼叫账号1001加入会议3000
freeswitch@iZuf6fya4> conference 3000 vid-floor 2 force
Freeswitch使用自签证书
freeswitch使用自签证书,配置WSS_Bang的博客-CSDN博客_freeswitch wss配置
SIP相关知识内容
SIP头域说明
Request-URI | 呼叫请求发送地址。UA生成初始请求消息时,该域中的信息一般与TO中的地址相同,经过网络服务器后,由于实际路由问题,该值可能发生变化以,另外一个比较特殊的是REGISTER消息,在REGISTER消息中,在REQUEST-URI中将会填充注册服务器的地址(表示消息发往注册服务器),而此时TO域中的地址将会填充客户端实际的地址。 |
From | 发起请求方的地址。一般采用USERINFO@HOSTPORT形式。该域同时带有一个TAG参数,是随机产生的整数。 |
To | 接受方地址。同FROM域相同,也采用USERINFO@HOSTPORT的地址形式,当该域存在于最终响应消息中时,将会事有TAG参数。 |
Call-ID | 用于识别呼叫参数,在同一个DIALOG中,该参数不发生变化。该参数与FROM中的TAG参数、TO域中的TAG参数相结合用以保证呼叫的惟一性。 |
Cseq | 表征TRANSACEION的参数,由于同一个呼叫中会存在多个TRANSACTION,因此通过该能数来保证同一个USERAGENT发送的不同请求消息间的顺序。 |
Via | 该参数表征呼叫经过的路径,UA生成SIP消息时,会在该域中填写自己的地址:PROXY在转发请求消息时,将会增加一个填有自己地址的VIA域,表示才叫经过本PROXY。VIA域的存在可以保证响应消息按照原路径返回到主叫方。代理服务器用它检查其内容,如果新端点已出现在via列表中,则表示有环路了。 |
Contact | 告知对端自己的地址。当对端发送下一个请求消息时,可直接向该地址发送,不需要关心前一个路由信息(除非有特定原则,例如PROXY可以通过RECORD-ROUTE域来保证下一个请求消息必须经过本PROXY,即使CONTACT域中填写对端客户的地址。 |
Expires | limits search time, 给出消息内容超期的时间 |
Record-Route | 由于CONTACT域的存在使得两个用户后续的请求消息可能不经过PROXY,为了运营需要,PROXY在初始INVITE消息中增加了RECORD-ROUTE域,这样可以保证后续请求(例如BYE消息)经过PROXY.通过RECORD-ROUTE与CONTACT的结合,既可避免后续请求旁路网络服务器的行为,又可减少后续请求路径上的环节。 |
CONTENT-TYPE | 表征消息格式的参数,例如,呼叫采用了SDP进行会话描述,还是采用其他类型的会话描述协议。 |
SIP Status Mapping
Q.850 Cause Value Number | Q.850 Cause Value Number | SIP Status Number | SIP Status Text | Comments |
---|---|---|---|---|
1 | Unallocated number | 404 | Not found | N/A |
2 | No route to specified transit network | 404 | Not found | N/A |
3 | No route destination | 404 | Not found | N/A |
16 | Normal calling clearing | N/A | BYE message | A call clearing BYE message containing cause value 16 normally results in the sending of a SIP BYE or CANCEL request. However, if a SIP response is to be sent to the INVITE request, the default response code should be used. |
17 | User busy | 486 | Busy here | N/A |
18 | No user responding | 408 | Request timeout | N/A |
19 | No answer from the user | 480 | Temporarily unavailable | N/A |
20 | Subscriber absent | 480 | Temporarily unavailable | N/A |
21 | Call rejected | 603 | Decline (if location filed in Cause information element indicates user; otherwise 403 Forbidden is used) | N/A |
22 | Number changed | 301 | Moved permanently (if information in diagnostic field of Cause information element is suitable for generating SIP Contact header; otherwise 410 Gone is used) | N/A |
23 | Redirection to new destination | 410 | Gone | N/A |
25 | Exchange routing error | 483 | Too many hops | N/A |
27 | Destination out of order | 502 | Bad gateway | N/A |
28 | Address incomplete | 484 | Address incomplete | N/A |
29 | Facility rejected | 501 | Not implemented | N/A |
31 | Normal, unspecified | 480 | Temporarily unavailable | N/A |
34 | No circuit, channel unavailable | 503 | Service unavailable | N/A |
38 | Network out of order | 503 | Service unavailable | N/A |
41 | Temporary failure | 503 | Service unavailable | N/A |
42 | Switching equipment congestion | 503 | Service unavailable | N/A |
47 | Resource unavailable unspecified | 503 | Service unavailable | N/A |
55 | Incoming calls barred with CUG | 403 | Forbidden | N/A |
57 | Bearer capability not authorized | 403 | Forbidden | N/A |
58 | Bearer capability not presently available | 503 | Service unavailable | N/A |
65 | Bearer capability not implemented | 488 | Not acceptable here | N/A |
69 | Requested facility not implemented | 501 | Not implemented | N/A |
70 | Only restricted digital information available | 488 | Not acceptable here | N/A |
79 | Service or option not implemented, unspecified | 501 | Not implemented | N/A |
87 | User not member of CUG | 403 | Forbidden | N/A |
88 | Incompatible destination | 503 | Service unavailable | N/A |
102 | Recovery on timer expiry | 504 | Server time-out | N/A |