freeswich学习

编程入门 行业动态 更新时间:2024-10-14 10:46:16

freeswich学习

freeswich学习

写在前面

因为所在部分主要负责公司客服业务,需要了解freeswich相关内容,所以这里将学习内容记录下。

1:安装freesswich

freeswich是一个实现了软交换协议的开源软件,可以对对接运营上的通话线路,实现拨打电话。

  • 安装依赖
yum install -y .noarch.rpm epel-release yum install -y yum-utils --enablerepo=extras yum install -y yum-plugin-ovl centos-release-scl rpmdevtools yum-utils git wget vim devtoolset-7-gcc* devtoolset-7 libtiff-devel cmake3 libatomic unixODBC unixODBC-devel.x86_64 postgresql-libs postgresql-devel libpqxx-develyum install -y gcc-c++ autoconf automake libtool ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre-devel speex-devel ldns-devel libedit-devel libxml2-devel libyuv-devel libvpx-devel libvpx2* libdb4* libidn-devel unbound-devel libuuid-devel lua-devel libsndfile-devel yasm-devel
  • 下载源码并编译
cd /data
git clone -b v1.10.7 
cd /data/freeswitch
git clone .git
git clone .git#编译spandsp
cd /data/freeswitch/spandsp
./bootstrap.sh
./configure
make
make install#编译sofia-sip
cd /data/freeswitch/sofia-sip
./bootstrap.sh
./configure
make
make install#添加库的路径到系统
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} 
ldconfig# 编译fs
cd /data/freeswitch
./bootstrap.sh
./configure --enable-portable-binary --prefix=/usr/local/freeswitch --with-gnu-ld --with-python --with-openssl --enable-core-odbc-support --enable-zrtp
make
make install

注意:如果报错,找到modules.conf文件,将报错的模块注释掉即可。如#applications/mod_signalwire #applications/mod_av,具体根据当时的情况看吧,谁报错就注释掉谁。

  • 启动
[root@localhost bin]# pwd
/usr/local/freeswitch/bin
[root@localhost bin]# ./freeswitch -nonat
2023-11-07 17:14:18.156329 0.00% [INFO] switch_event.c:713 Activate Eventing Engine.
...
2023-11-07 17:14:20.946405 0.00% [CONSOLE] switch_core.c:2544 
.=============================================================.
|   _____              ______        _____ _____ ____ _   _   |
|  |  ___| __ ___  ___/ ___\ \      / /_ _|_   _/ ___| | | |  |
|  | |_ | '__/ _ \/ _ \___ \\ \ /\ / / | |  | || |   | |_| |  |
|  |  _|| | |  __/  __/___) |\ V  V /  | |  | || |___|  _  |  |
|  |_|  |_|  \___|\___|____/  \_/\_/  |___| |_| \____|_| |_|  |
|                                                             |
.=============================================================.
|   Anthony Minessale II, Michael Jerris, Brian West, Others  |
|   FreeSWITCH ()                    |
|   Paypal Donations Appreciated: paypal@freeswitch       |
|   Brought to you by ClueCon /         |
.=============================================================..=======================================================================================================.
|       _                            _    ____ _             ____                                       |
|      / \   _ __  _ __  _   _  __ _| |  / ___| |_   _  ___ / ___|___  _ __                             |
|     / _ \ | '_ \| '_ \| | | |/ _` | | | |   | | | | |/ _ \ |   / _ \| '_ \                            |
|    / ___ \| | | | | | | |_| | (_| | | | |___| | |_| |  __/ |__| (_) | | | |                           |
|   /_/   \_\_| |_|_| |_|\__,_|\__,_|_|  \____|_|\__,_|\___|\____\___/|_| |_|                           |
|                                                                                                       |
|    ____ _____ ____    ____             __                                                             |
|   |  _ \_   _/ ___|  / ___|___  _ __  / _| ___ _ __ ___ _ __   ___ ___                                |
|   | |_) || || |     | |   / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \                               |
|   |  _ < | || |___  | |__| (_) | | | |  _|  __/ | |  __/ | | | (_|  __/                               |
|   |_| \_\|_| \____|  \____\___/|_| |_|_|  \___|_|  \___|_| |_|\___\___|                               |
|                                                                                                       |
|     ____ _             ____                                                                           |
|    / ___| |_   _  ___ / ___|___  _ __         ___ ___  _ __ ___                                       |
|   | |   | | | | |/ _ \ |   / _ \| '_ \       / __/ _ \| '_ ` _ \                                      |
|   | |___| | |_| |  __/ |__| (_) | | | |  _  | (_| (_) | | | | | |                                     |
|    \____|_|\__,_|\___|\____\___/|_| |_| (_)  \___\___/|_| |_| |_|                                     |
|                                                                                                       |
.=======================================================================================================.2023-11-07 17:14:20.946482 0.00% [INFO] switch_core.c:2553 

停止命令 ./freeswich -stop

  • 查看端口号

会启动好几个端口,各有各的作用。

[root@localhost bin]# netstat -nlp|grep frees
tcp        0      0 192.168.192.128:7443    0.0.0.0:*               LISTEN      118580/./freeswitch 
tcp        0      0 192.168.192.128:5080    0.0.0.0:*               LISTEN      118580/./freeswitch 
tcp        0      0 192.168.192.128:5060    0.0.0.0:*               LISTEN      118580/./freeswitch 
tcp        0      0 192.168.192.128:5066    0.0.0.0:*               LISTEN      118580/./freeswitch 
tcp6       0      0 :::8021                 :::*                    LISTEN      118580/./freeswitch 
tcp6       0      0 ::1:5080                :::*                    LISTEN      118580/./freeswitch 
tcp6       0      0 ::1:5060                :::*                    LISTEN      118580/./freeswitch 
udp        0      0 192.168.192.128:5060    0.0.0.0:*                           118580/./freeswitch 
udp        0      0 192.168.192.128:5080    0.0.0.0:*                           118580/./freeswitch 
udp6       0      0 ::1:5060                :::*                                118580/./freeswitch 
udp6       0      0 ::1:5080                :::*                                118580/./freeswitch 

2:安装软电话

模拟真实的电话,客服使用的就是这玩意,从这里 下载,下载后,按照如下配置注意ip改成你自己的

变为下图就成功了:

此时我们就可以通过freeswich呼叫软电话了通过fs提供的fs_cli工具和originate命令

[root@localhost bin]# ./fs_cli -H 127.0.0.1 -p ClueCon
.=======================================================.
|            _____ ____     ____ _     ___              |
|           |  ___/ ___|   / ___| |   |_ _|             |
|           | |_  \___ \  | |   | |    | |              |
|           |  _|  ___) | | |___| |___ | |              |
|           |_|   |____/   \____|_____|___|             |
|                                                       |
.=======================================================.
| Anthony Minessale II, Ken Rice,                       |
| Michael Jerris, Travis Cross                          |
| FreeSWITCH ()                |
| Paypal Donations Appreciated: paypal@freeswitch   |
| Brought to you by ClueCon /     |
.=======================================================..=======================================================================================================.
|       _                            _    ____ _             ____                                       |
|      / \   _ __  _ __  _   _  __ _| |  / ___| |_   _  ___ / ___|___  _ __                             |
|     / _ \ | '_ \| '_ \| | | |/ _` | | | |   | | | | |/ _ \ |   / _ \| '_ \                            |
|    / ___ \| | | | | | | |_| | (_| | | | |___| | |_| |  __/ |__| (_) | | | |                           |
|   /_/   \_\_| |_|_| |_|\__,_|\__,_|_|  \____|_|\__,_|\___|\____\___/|_| |_|                           |
|                                                                                                       |
|    ____ _____ ____    ____             __                                                             |
|   |  _ \_   _/ ___|  / ___|___  _ __  / _| ___ _ __ ___ _ __   ___ ___                                |
|   | |_) || || |     | |   / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \                               |
|   |  _ < | || |___  | |__| (_) | | | |  _|  __/ | |  __/ | | | (_|  __/                               |
|   |_| \_\|_| \____|  \____\___/|_| |_|_|  \___|_|  \___|_| |_|\___\___|                               |
|                                                                                                       |
|     ____ _             ____                                                                           |
|    / ___| |_   _  ___ / ___|___  _ __         ___ ___  _ __ ___                                       |
|   | |   | | | | |/ _ \ |   / _ \| '_ \       / __/ _ \| '_ ` _ \                                      |
|   | |___| | |_| |  __/ |__| (_) | | | |  _  | (_| (_) | | | | | |                                     |
|    \____|_|\__,_|\___|\____\___/|_| |_| (_)  \___\___/|_| |_| |_|                                     |
|                                                                                                       |
.=======================================================================================================.Type /help <enter> to see a list of commands+OK log level  [7]
freeswitch@localhost.localdomain> originate user/1000 &echo
...

echo是回音测试。你说啥fs直接给你说啥那种。
效果如下图:

3:freeswich常用命令

3.1:api

同步执行freeswich内部的api,如api version:

api versionContent-Type: api/response
Content-Length: 113FreeSWITCH Version 1.10.7-release+git~20211024T163933Z~883d2cb662~64bit (git 883d2cb 2021-10-24 16:39:33Z 64bit)

3.2:bgapi

api的异步版本,不需要等待freeswich执行完毕,就会直接返回。

3.3:event

event命令用于订阅freeswitch的各种事件, 分别支持plain文本类型、xml类型和json类型的事件数据模式返回。

nodejs订阅所有事件:

//register system events, work well for CUSTOM event
conn.events('json', 'all', function(){
});

3.4:noevents /nixevent

取消事件订阅的命令:

/nixevent plain CHANNEL_ANSWER CHANNEL_HANGUP CHANNEL_HANGUP_COMPLETE

写在后面

参考文章列表

【FreeSwitch开发实践】centos7下编译安装freeswitch及常见编译问题的解决 。

【FreeSwitch开发实践】使用SIP客户端Yate连接FreeSwitch进行VoIP通话 。

更多推荐

freeswich学习

本文发布于:2023-11-15 23:02:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:freeswich

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!