我在XMPP框架的帮助下实现了一个聊天应用程序。但是我收到了一个错误,如下所示:
xmpp did receive error:-
Printing description of error:
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams"></conflict><text xmlns="urn:ietf:params:xml:ns:xmpp-streams" lang="">Replaced by new connection</text></stream>需要一些关于什么可能导致此错误以及如何使用XMPP重新连接的指导。
谢谢。
发布于 2014-08-12 07:16:59
使用XMPPReconnect类..。
@property (nonatomic, readonly) XMPPReconnect *xmppReconnect;
self.xmppReconnect = [[XMPPReconnect alloc] init];
[self.xmppReconnect activate:self.xmppStream];
[self.xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];并实现'XMPPReconnect‘委托方法
- (void)xmppReconnect:(XMPPReconnect *)sender didDetectAccidentalDisconnect:(SCNetworkReachabilityFlags)connectionFlags
{
NSLog(@"didDetectAccidentalDisconnect:%u",connectionFlags);
}
- (BOOL)xmppReconnect:(XMPPReconnect *)sender shouldAttemptAutoReconnect:(SCNetworkReachabilityFlags)reachabilityFlags
{
NSLog(@"shouldAttemptAutoReconnect:%u",reachabilityFlags);
return YES;
}发布于 2016-01-26 01:15:44
我相信,当客户端从服务器接收到此错误时,XMPPReconnect将停止工作。检查XMPPReconnect.m。您将在委托函数中看到,当收到此错误时,变量shouldReconnect设置为NO,这意味着将不再进行重连接尝试。
解释是,当另一个客户端使用相同的资源进行连接时,“通常”会收到此错误,因此将禁用XMPPReconnect,以避免两个不同客户端和服务器之间无休止的重新连接和断开连接。
但是,我注意到,即使只有一个客户端连接,有时也会出现此错误。因此,如果您确信没有两个不同的客户端将尝试同时连接到服务器,那么我建议将行shouldReconnect注释为NO,从而允许XMPPFramework将其视为一个普通的断开连接。
https://stackoverflow.com/questions/25257993
复制相似问题