几种XMPP客户端实现Jingle语音聊天的总结
XMPP客户端除了最基本的发送/接收消息,显示好友列表等功能外,语音/视频聊天,文件传输等功能也很有必要. 而XMPP Jingle是实现媒体流的协议. 既然一些客户端和服务器都支持XMPP Jingle, 所以就想测试一下语音聊天的功能.
这里要测试的XMPP客户端有Psi和Spark, 要测试XMPP服务器有Openfire和Google GTalk Server (talk.google.com:5222).
我的网络环境是, 家里有2台笔记本,都通过Wifi连接到无线路由器,而无线路由器通过ADSL连接到外网. 每台笔记本都安装一个客户端, 然后想通过两个客户端来语音聊天. 其中在一个笔记本上同时安装了Openfire服务器.
下面就是我整个测试过程,步骤挺曲折的,无数次失败,好在总算摸清了规律,并且成功了一个case.
Case 1: LaptopA安装了Spark和Openfire, LaptopB安装了Spark.
接收方可以收到语音聊天邀请,但Accept后,发送方或者接收方最后会提示"Session closed due to Closed Remotely"或者"Voice chat ended: No Media Received. This may be caused by firewall configuration problems."
在网上发现很多人也遇到过这样的问题, 但至今没有答案, 而且我将firewall关闭后还是不行. 分析XMPP packets, 一切都是正常的.
<iq id="fSjYO-68" to="zhangsan@hj.com/spark" from="lisi@hj.com/spark" type="set"> <jingle xmlns="http://jabber.org/protocol/jingle" initiator="lisi@hj.com/spark" responder="zhangsan@hj.com/spark" action="transport-info" sid="5856340275725448398"> <content name="Audio-Content"> <transport xmlns="http://jabber.org/protocol/jingle/transport/ice"> <candidate generation="1" ip="hj.com" port="16552" network="1" username="1" password="2011457701536237394" preference="0" type="relay"/> </transport> </content> </jingle></iq><iq id="XUxSY-71" to="lisi@hj.com/spark" from="zhangsan@hj.com/spark" type="set"> <jingle xmlns="http://jabber.org/protocol/jingle" initiator="lisi@hj.com/spark" responder="zhangsan@hj.com/spark" action="transport-info" sid="5856340275725448398"> <content name="Audio-Content"> <transport xmlns="http://jabber.org/protocol/jingle/transport/ice"> <candidate generation="1" ip="192.168.1.102" port="11294" network="0" username="1" password="5230389440376589888" preference="2195" type="prflx"/> </transport> </content> </jingle></iq>
<iq type="set" to="zhangsan@hj.com/A23" id="aac0a" ><jingle xmlns="urn:xmpp:jingle:1" initiator="lisi@hj.com/laptop-hj" action="session-initiate" sid="uIHg21D8Q8UJkWsf" ><content creator="initiator" name="A" senders="both" ><description xmlns="urn:xmpp:jingle:apps:rtp:1" media="audio" ><payload-type id="110" name="SPEEX" clockrate="16000" /></description><transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" pwd="dODoWCJnXPqeIneJwCrA28" ufrag="2PAp" /></content></jingle></iq><iq from="zhangsan@hj.com/A23" type="result" to="lisi@hj.com/laptop-hj" id="aac0a" /><iq type="set" to="zhangsan@hj.com/A23" id="aac1a" ><jingle xmlns="urn:xmpp:jingle:1" action="transport-info" sid="uIHg21D8Q8UJkWsf" ><content creator="initiator" name="A" ><transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" pwd="dODoWCJnXPqeIneJwCrA28" ufrag="2PAp" ><candidate generation="0" network="0" port="8010" protocol="udp" component="1" foundation="0" ip="127.0.0.1" priority="2130706431" type="host" id="my51NYF8wP" /><candidate generation="0" network="0" port="8011" protocol="udp" component="2" foundation="0" ip="127.0.0.1" priority="2130706430" type="host" id="LS4DE8k7vO" /></transport></content></jingle></iq><iq from="zhangsan@hj.com/A23" type="set" to="lisi@hj.com/laptop-hj" id="aac1a" ><jingle xmlns="urn:xmpp:jingle:1" action="transport-info" sid="uIHg21D8Q8UJkWsf" ><content creator="initiator" name="A" ><transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" pwd="eLRa7cHeUu54G0DsHCss1C" ufrag="Tfvb" ><candidate generation="0" network="0" port="8010" protocol="udp" component="1" foundation="0" ip="192.168.1.102" priority="2130706431" type="host" id="tOKbYm1G9C" /><candidate generation="0" network="0" port="8011" protocol="udp" component="2" foundation="0" ip="192.168.1.102" priority="2130706430" type="host" id="LYcHQKgbQy" /></transport></content></jingle></iq><iq type="result" to="zhangsan@hj.com/A23" id="aac1a" /><iq from="zhangsan@hj.com/A23" type="result" to="lisi@hj.com/laptop-hj" id="aac1a" /><iq from="zhangsan@hj.com/A23" type="set" to="lisi@hj.com/laptop-hj" id="aac2a" ><jingle xmlns="urn:xmpp:jingle:1" action="session-terminate" sid="uIHg21D8Q8UJkWsf" ><reason><gone/></reason></jingle></iq><iq type="result" to="zhangsan@hj.com/A23" id="aac2a" />