Best SIP client soft phone is GS Wave

I have tried almost every VOIP soft phone app on Google Play. Before I found GS Wave, I reckoned Zoiper app was the best soft phone, thus I paid for its premium version to get its premium feature of video call.

However I never got this feature working. I wanted to see the video from my video door phone on my mobile with Zoiper. My video door phone supports H264 video codec but Zoiper supports VP8 unless I pay Zoiper again just for H264 codec . Unlike audio codec while a VOIP server can translate audio codec between clients, video codec is said to be P2P. (There may be a way of video codec translation, but I don’t know how.)

I had video calls working between my video door phone and desktop SIP phones which are “hard phones” with H264 built in. And I had audio calls working on all devices. So I was not desperate for video on Zoiper.

Zoiper has a major defect. It cannot stay online 24/7 on latest Android version (I tested on two Huawei Mate 8 and one P9) or iOS. Many times status bar shows it is online but actually it is not reachable. Zoiper was reliable on Android 4.x.x. I guess Zoiper “forgets” to re-register itself when OS goes into sleep. For above reasons I am reluctant to pay Zoiper any more money.

Recently I visited Fanvil website and discovered Fanvil had developed a soft phone called “Vdroid” for free download. To my surprise, Vdroid integrated G729 audio codec and H264 video codec. They are premium codec as on Zoiper. (Later on I learnt G729 patent expired on 1st Jan, 2017 but Zoiper is still selling G729 for money. I knew nothing about H264.) However Vdroid has too many bugs and is not a mature software.

Then I thought other VOIP device manufacturers might have their own soft phones for public. I checked Grandstream, Yealink and Cisco but only found Grandstream generously offering GS Wave. GS Wave has both Android and iOS version, and both works reliably, and both has G729 and H264 built in for free! I cannot wait any longer to recommend GS Wave to everyone. Google Play is overwhelmed by other apps for search results of “sip” or “voip”, and GS Wave is nowhere in the ranking. But trust me, it is the best one.

 

Zoiper cannot stay online on mobile phones

Zoiper 是我青睐的一个 VOIP 客户端,最大好处是它同时支持 SIP 和 IAX2 协议,最大坏处是它太想捞钱,竟然把视频通话功能归入收费版本。

言归正传,我在使用 Zoiper 过程中,发现 Zoiper 里的 SIP 或 IAX2 帐号在手机上不能稳定在线,通常是在手机屏幕熄灭 5 秒钟进入锁屏状态(默认设置)后,Zoiper 就掉线了;如果锁屏前 Zoiper 是当前窗口,则在锁屏后存活的几率大大提高,但仍免不了掉线。

另外有几个发现:

  • 如果在平板上使用 Zoiper,则非常稳定。
  • 在 Huawei P8 手机上使用 Zoiper,也非常稳定,真是个奇迹。性能更好的 Mate 7, Mate 8 在这方面都不如 P8。
  • 在绝大部分手机上使用 Zoiper,一旦掉线,Zoiper 不会(或看上去不会)自动重试上线。
  • 手机在充电时使用 Zoiper,则比不充电时要略稳定。

如果 Zoiper 不稳,那我就无法把重要来电转接到 VOIP。所以我花了点时间一一对比了 P8 和其他手机上 Zoiper 的设置。虽然我仍未发现 P8 上 Zoiper 能站稳的原因,但我发现,在电源省电管理里,给 Zoiper 选中“锁屏后保护进程”对其稳定在线是有好处的。默认未选中,P8 上的默认也是未选中,但 Zoiper 就是稳,所以我不理解。

不管怎样,“锁屏后保护进程”让 Zoiper 在 Mate 7 和 Mate 8 上稳定了好多,但又来了新问题——大大增加了另一种掉线的概率,错误信息:“503 Transport failure: no transports left to try”。我搜了一下,不知所云。

不过,我发现这个错误只针对 SIP 帐号。IAX2 帐号在选中“锁屏后保护进程”的手机上能稳定在线,期间经历 Wi-Fi / 4G / 3G 的来回切换,Zoiper 都能网络恢复后自动上线。幸好 IPPBX 的控制权也在我,那以后就在手机上用 IAX2 帐号吧。

Huawei mobile phone China release VS international release

我用手头的 Mate 7, Mate 8, P8 总结了几点华为国内版和国际版的区别。

1、谷歌被阉割。这个折腾一下是可以续上,但整个系统感觉不是浑然天成。

再谈下几个硬伤:

2、电话拨号程序里没有内置 Internet call,显然官方仍视 VOIP 如洪水猛兽。

3、电话拨号程序里多了阻止响一声的骚扰电话,IP 固定拨号,黄页号簿,都是跟国内用户需求有关,出了国就是鸡肋。

4、Browser(系统提供的浏览器)提供四个搜索提供商:搜索大全,百度,谷歌,淘宝,如果设定为谷歌,则为中国的谷歌,搜索时询问是否跳转到香港谷歌,非常烦人,而且无法添加新的搜索提供商,这几乎废掉了 Browser。

5、华为穿戴一定要输入华为帐号才能使用,而我之前用过华为穿戴就没有这种限制,我就特别气愤这种中外歧视(特指给外国人的优惠不给国人),就丢开华为穿戴不用。后来发现只要把区域改为英国,Huawei Wear 就不再询问华为帐号。

最后谈谈国内版的好处:

6、Calendar 系统应用里的 Calendars to be displayed 有一个 Other 组,可以选中显示农历,这个选择不随区域的修改而失效。我就是看它知道今年春节是 2 月 8 日。

7、Video 系统应用并不仅是视频播放器,而更像一个类似 Youtube 的视频内容提供商。我在里面可以找到很多中国的节目,其中少儿内容也很多,弥补了 Youtube 的不足。速度还可以。

Install Freepbx 13 on CentOS 7

FreePBX Wiki 有一篇关于如何在 CentOS 7 上安装 FreePBX 13 详细的指导。我不想重复具体的步骤,只想说说如何解决在安装后出现的问题。

我在 OpenVZ VPS 的 CentOS 7.0 minimal 环境下依次执行了 FreePBX 13 安装指导的各项命令,期间并没有发现问题,下载、编译都很顺利。安装完成以后,发现虽能访问 FreePBX web UI,但对 FreePBX 进行的第一项测试——添加一个分机,就卡住了——注册不了。这时 VPS 还未重启过,虽然指导上没有让重启,那就重启一下看看呗。重启之后,更糟,首先发现 FreePBX web UI 访问不了,然后发现 ssh 也登录不了,最后发现连 ping 也不响应。只好用 serial console 登录后排查,发现 network 服务没启动,手动重启 network 服务也失败。

我只好把安装步骤分解,首先定位到是 yum groupinstall core 群组件造成 network 服务启动失败,然后再分解,发现是其中的 selinux* 和 NetworkManager 两个软件包的问题。定位这两个软件包花了我很长时间,这里按下不表。幸好这两个软件包也不是 FreePBX 所需要的,所以把它们卸载之后,network 服务就能正常启动了。FreePBX 安装指导提到需要将 SELinux 关闭,SELinux 也确实处于关闭状态,但它由 core 群组件安装后还是对 network 造成了困扰,卸载当然是最好的选择;NetworkManager 跟 network 冲突,似乎很久以前也碰到过,只是这次没有在第一时间想到是 NetworkManager 的问题,是地毯式排查中发现的。

网络正常后,就能访问到 FreePBX web UI,但 dashboard 上提示无法连接到 asterisk 服务。我再回头看安装命令,其中一项是 chkconfig asterisk off。我其实挺不理解的,为什么特意不让 asterisk 自启动,当时以为安装过程中暂时将它关闭,会在后期的脚本里配置好,让 asterisk 自启动。可事实上是 asterisk 没有自启,因此我认为 chkconfig asterisk off 是原作者笔误,应该是 chkconfig asterisk on。

另外,安装过程中特意执行了

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

这是开放 80 端口。我就纳闷了——作为一个 VoIP server,仅开放 80 端口有什么用?!之后发现,5060 端口也是开放的,因此 SIP 分机注册没有问题。我没见哪条指令将它打开,估计是在某个脚本里了。但是,还有好些端口,比如 RTP 默认端口 10000-20000,不打开这些端口听筒里就没有声音。我试了一下,果然没有声音。FreePBX 安装指导没有提及更多的 firewall 的设置,这需要在安装完成后自行设置。

执行到此,似乎就可以了,我添加了分机,并注册、互呼成功。但运行了大约半小时左右,再次添加一个分机,Apply Config 时,出现以下错误:

Reload failed because retrieve_conf encountered an error: 1

exit: 1
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
Exception: Unable to connect to Asterisk through the CLI in file /var/lib/asterisk/bin/retrieve_conf on line 24
Stack trace:
1. Exception->() /var/lib/asterisk/bin/retrieve_conf:24
1 error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.

这是因为 /var/run/asterisk/asterisk.ctl 在 asterisk 重启之后,属主、属组被修改为 root:root,而正常的应该是 asterisk:asterisk。为什么一开始的时候还能 Apply Config,一定时间后才出现问题?这个机理我搞不懂了。

Updated 20/12/2015:这个机理我猜想是 asterisk 有一个守护进程,在异常时会重启 asterisk,用户通常不会觉察到 asterisk 已重启,但这时 Apply Config 就被拒绝。解决办法是在 /etc/asterisk/asterisk.conf 增加以下内容,可以让 /var/run/asterisk/asterisk.ctl 保持属主、属组都为 asterisk。

[files]
astctlpermissions = 0660
astctlowner = asterisk
astctlgroup = pbx
astctl = asterisk.ctl

Allow specific “anonymous” inbound SIP calls

之前所有的 SIP 服务商都是提供 SIP 注册的帐号和密码。最近碰上一个新的 SIP 服务商,购买了一个电话号码,它只让我设置 Forward to SIP Server 或 Forward to SIP URI(当然也可以转发到普通电话号码,但那是要额外收费的,不在我考虑范围之内)。

于是,碰到了新命题:我必须在 FreePBX 的 SIP Settings 里同时启用 Allow SIP Guests 和 Allow Anonymous Inbound SIP Calls 才能收到转发过来的 SIP calls。这两项都是我不愿意启用的设置,因为存在被 SIP hackers spamming 的风险。尽管单独启用 Allow SIP Guests 据说没有太大风险,但还是接不到电话,呼叫方会收到 FreePBX 给出的语音提示:The number you have dialed is not in service. Please check the number and dial again.

怎样才能让来自 SIP 服务商的 anonymous calls 通过,而把其他的阻挡在外?我甚至想到了启用 Allow SIP Guests 和 Allow Anonymous Inbound SIP Calls ,但用防火墙规则只允许来自特定 host / IP 的流量。这个方法我自我评价是非常 dirty,我希望是 FreePBX 的问题在 FreePBX 内部解决。

我几乎不带希望,搞了个试验,创建了一个 SIP trunk。它跟之前注册型的 SIP trunk 的区别就是省略了 PEER Details 项里的 username, password 和 Register String。然后,同时禁用 Allow SIP Guests 和 Allow Anonymous Inbound SIP Calls,这时 Forward to SIP URI 已经能工作;再添加一条 Inbound Route,Forward to SIP Server 也能工作了。

这个事实推翻了我对 trunk 的原有理解—— trunk 只是一条进或出的通路。现在我知道 trunk 还能“命名”符合特定条件的“匿名”来电,起到过滤的作用。

此外,我猜想,转发型的 SIP 服务比注册型的 SIP 服务更可靠,因为转发型的 SIP 只在有来电时把数据包转发到我的 FreePBX;而注册型的 SIP 则要不时地重注册保持连接,有时连接已经断开,而 FreePBX 不知道,要等到下个周期才重注册,于是会错过来电。不知我猜想对否?请教过路的 VOIP 专家。

 

5V2A adapter for IAD

前不久在淘宝上淘了一个华为 U-SYS IAD101H,准备用作 MGCP 语音网关。才 28 元人民币,运费 6 元,真的很便宜。

Huawei U-SYS IAD101H
Huawei U-SYS IAD101H

卖家说明自配变压器,是 5V2A 的电源。我加钱求卖家帮我配好变压器,但卖家不帮忙。因为语音网关还未转寄到我手上,所以我也没急着寻购 5V2A 变压器。今天无意中在我家电视机柜边上翻出一个孤零零的变压器,一看正好是 5V2A。我想了半天没想出它是哪个设备元配的变压器,先拿来用了再说。

5V2A adapter
5V2A adapter

Newbie’s experience in setting up an IPPBX

I classify myself as a newbie as I have been diving into Asterisk / FreePBX for only 3 months. I am not familiar with 95% parameters of my IPPBX, and I try to avoid touching those parameters. However I can proudly say I have gained enough experience in setting up an IPPBX for a commercial environment, and I want to share it with you.

Before I start, I have to make it clear what my goals are, so you know if my experience suits you.

Firstly, I do not have massive users, say less than 100. We did not use any PBX, but once we launch IPPBX, it must be working very stably.

Secondly, users should be able to pick up the calls in the office, at home or on the move. Myself is a typical user, who answer 1/3 calls in the office, 1/3 at home, 1/3 on the move.

Thirdly, I want to save every pence possible on this first IPPBX. There are many IPPBX with Asterisk preinstalled and probably optimised on the market, whose prices start from £150. However I think at £150 it is an entry level product and geared for a SOHO enviroment. If I hunt for a proper commercial Asterisk IPPBX, I should look for something above £300.  I am a fanatical DIYer and I believe business can take advantage of open source. Free open source allows business to do the same things other highly priced product can do, and sometimes does better. Of course the price of open source is the learning time. I spent £100 on the hardware (Bought from China directly. I evaluate it as £190 for similar hardware on the UK market), and 3 months in learning. A commercial Asterisk IPPBX with the equivalent capacity should be priced at £500 or so.

My 3 months’ learning only saved £400 which is a loss. Nevertheless, back to the topic – my gained experience in setting up an IPPBX.

I do not need to connect IPPBX to a physical analogue (POTS) or digital (ISDN) telephone line. If you do, and the more lines to connect, the more worthwhile to buy a commercial IPPBX with FXO or BRI ports built in. None of analogue/digital cards or ATA or ISDN gateways are cheap.

At the time of choosing a DIY IPPBX other than a commercial IPPBX, I was quite worrying about the stability. Now I can say software stability can be achieved by a newbie like me. But to make the whole system work reliably, I have to buy a decent hardware to run it on, and most importantly, a reliable network. My current ISP is horrible and due to be switched away in next month. It wasted me a lot of time debugging – barking at the wrong tree. I would not say “horrible” if I was only using their network browsing Internet. It looks like it can not afford VOIP traffic when it comes to host an IPPBX.

I set port forwarding on the NAT router where IPPBX is. I forwarded SIP bind port and RTP ports. I did not do everything at client side router. The SIP client should traverse a router not in my control.

I put NAT in Settings >> Asterisk SIP Settings to “route”, which instantly solved a lot of audio silence between various devices, i.e. high end SIP phone, entry level SIP phone, and several soft SIP phones installed on several Android based mobiles. I still can not understand the exact logical behavior of “yes”, “no”, “never”, “router” for NAT choice, but to me, “router” is the best choice.

I totally understand many people says SIP behind NAT is a nightmare. My IPPBX is behind a NAT router in the office, and if I am at home, my extension is behind another NAT router. This is the worst scenario. With FreePBX Distro and the above simple configuration, but without help of any third party modules, proxy, stun server, SER, the most difficult problem I encountered is one way audio on some devices / soft phones. It is always the caller can not hear voice from the callee, but the callee can.

Then I find enabling stun server on SIP client does not do anything good. Actually I find enabling Rport for signaling and media helps eliminating one way audio symptom if this choice is available. If your device does not have such a choice, but you have two devices at hand, you can dial out using one of them and transfer the call to the other one. This method makes both ends callees. So tricky. Do we really to do that? No. I have better way later on.

Missing codecs may cause audio silence, but it has nothing to do with one way audio. If a required codec is missing, both ends will be silent. I have a weird SIP trunk provider supplying 2 lines. Both lines have an external number (connecting PSTN) and an internal number (extension number on his SIP server). It turned out he enables different codecs for these 2 lines. And even on the same line, he enables different codecs for external number and internal number. It took me a long time before I realised it was a codec problem.

Although Android mobiles are widely available, it is worth buying SIP phones for office and home.  SIP phones can stay online much more stable than any of soft SIP phones on Android mobile. It may not be a fault of soft phones. They are restricted by Android power management. The advantage of Android devices is you can choose SIP apps to install. To get the best of both worlds, the best buy is an SIP desktop phone with Android OS.

Among SIP apps, I recommend Zoiper (most stable, and support IAX2), CSipSimple (support video calls with CSipSimple video plugin), Samsung Galaxy built in SIP client (may be best choice in power saving), in turn.

It is time to summarise how to tackle one way audio. I mentioned IAX2. Yes, for soft phone, use it as the first choice over SIP. (Sadly as a hardware, VOIP phone with IAX protocol are not widely available.) I am using Zoiper on the move. In the office, as it in the same subnet, SIP traversing is not a problem, so any SIP phones will do the job. At home, use a SIP phone which can enable Rport, or use Zoiper.

I tried to achieve a stable IPPBX without having to periodically reboot it, but I could not. The IPPBX runs into a hanging state every a few days. For example, all trunks / extensions are disconnected. Even “amportal restart” can not solve the problem. A daily reboot is a must. Just choose a quietest time and use crontab to reboot. My IPPBX reboots in 34 seconds, which means the uptime is 99.96%. Normally the IPPBX will not hang within a day. But I set a monitoring script anyway to monitor if all trunks / extensions lose connection, reboot the IPPBX immediately. It never happened so far.

I also find IPPBX daily rebooting is a usual practice. I have monitored two of my SIP trunk providers are rebooting their servers daily. I am going to test it on a third one. Besides, I will be very glad to see a future version of FreePBX can run without rebooting for years as Nginx, etc.

SIP requires very reliable network

我的 SIP 服务器 FreePBX 暂时还放在一个非常不可靠网络环境下,这在前文《FreePBX working with an unstable router》有提及,一有 SIP 不正常的风吹草动,我就成了惊弓之鸟。

今天早上我在家,发现 SIP 分机又出现单向语音的症状,测了多次,十次有九次是单向语音,主要是主叫方听不到对方声音。我在服务器上看来看去看不出原因,不管三七二十一,又重启了一次,仍没解决问题。

单向语音是 SIP 很常见的问题,在用 FreePBX 之初,我曾花大力气去解决,找到一套行之有效的办法。怎么今天又出现了老问题了?我一阵头疼。

我家的网络宽带路由器确实不太好,但一开始我没意识到是它的原因,因为浏览网页是正常的,再说 SIP 能注册,也能接通。我排查了很久,无意中将手机 Wi-Fi 连接关闭,用 3G 连接网络,手机的 SIP 客户端立刻就能双向语音,一切正常。我这才想到是网络宽带路由器的原因,把它重启了一遍,SIP 通话就正常了。

看来 SIP 对网络的要求非常高,而且是服务端、客户端双方的要求都很高。

Use Android mobile as a GSM gateway

I dream for an Android app which can make mobile serve as a GSM gateway. In many scenarios I need such an app.

  • I am abroad but I want to make calls to and receive calls from the UK contacts. I can leave the mobile in the UK on a charger, then connect to the mobile via Internet when abroad, via SIP protocal probably.
  • Call plan of mobile phone contract  has unlimited calls included, so I perfer to make calls via GSM network. But I also like to talk on the desktop IP phone, which make my business look professional.

In other words, I need an IP PBX app for Android, but no one made it available. Many apps of SIP client are on the marketplace, but no SIP server.