admin管理员组文章数量:1642239
1 问题描述
使用Strophe连接openfire,成功连接后。登录到openfire管理控制台,删除此人的会话,出现的现象是,Strophe重新连接openfire,但是连接成功,会立马断开连接,然后重连服务器
错误信息
2016.09.21 11:41:58 org.jivesoftware.openfire.http.HttpBindServlet - Error sending packet to client.
org.jivesoftware.openfire.http.HttpConnectionClosedException: The http connection is no longer available to deliver content
at org.jivesoftware.openfire.http.HttpConnection.deliverBody(HttpConnection.java:116)
at org.jivesoftware.openfire.http.HttpSession.forwardRequest(HttpSession.java:604)
at org.jivesoftware.openfire.http.HttpBindServlet.handleSessionRequest(HttpBindServlet.java:250)
at org.jivesoftware.openfire.http.HttpBindServlet.processContent(HttpBindServlet.java:205)
at org.jivesoftware.openfire.http.HttpBindServlet$ReadListenerImpl.onAllDataRead(HttpBindServlet.java:423)
警告信息
2016.09.21 13:01:54 org.jivesoftware.openfire.IQRouter - User tried to authenticate with this server using an unknown receipient: <iq type="get" to="1@192.168.4.187/Strophe" id="78e40236-b8f9-4205-8088-55249c2365ad:ping" from="192.168.4.187/y7uect7v1"><ping xmlns="urn:xmpp:ping"/></iq>
监控openfire接受的报文,收到的都是这样的信息
<iq type="get" to="1@192.168.4.187/Strophe" id="c0c40a9a-8c6c-4a68-ac32-523cec4d8104:ping" from="192.168.4.187/y7uect7v1">
<ping xmlns="urn:xmpp:ping"/>
</iq>
发送iq请求的js代码如下:
checkSeatOnline:function(to){
var seat = to+self.openfirefix;
var _success = function(resp){
console.log(resp);
}
var _error = function(resp){
console.log(resp);
window.clearInterval(self.seatOutLine);
$.closeModal();
$.confirm('客服已断开连接,是否重新连接?',function(){
window.location.reload();
},function(){
self.connection.disconnect("客服已断开");
self.openScoreDialog();
});
}
self.connection.ping.ping(seat,_success, _error);
}
2 问题分析
正常的发送消息,收到多条相同的iq节或message节。非常奇怪。
查看Strophe.js源码
Strophe.Connection中会启动一个空闲检测,检测时间为100ms。
this._idleTimeout = setTimeout(function() {
this._onIdle();
}.bind(this), 100);
在分析_onIdle的代码,如果连接成功后,100ms还会循环调用空闲检测。
if (this.connected) {
// XXX: setTimeout should be called only with function expressions (23974bc1)
this._idleTimeout = setTimeout(function() {
this._onIdle();
}.bind(this), 100);
}
根据现象推送原因,我们自己写的断开重连的方法,与openfire的空闲检测,因为时间差的问题,导致openfire反复重连。
版权声明:本文标题:Strophe反复重连openfire的问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729334114a1196765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论