Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reconnect with XMPP when user is getting error or disconnect from XMPP

Tags:

ios

xmpp

I have implemented a chatting application with the help of XMPP framework. But I am getting an error as shown :

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>

Need some guidance on what could be causing this error and how to reconnect using XMPP.

Thanks.

like image 527
jaydev Avatar asked Feb 12 '23 07:02

jaydev


1 Answers

Use XMPPReconnect class..

@property (nonatomic, readonly) XMPPReconnect *xmppReconnect;

self.xmppReconnect = [[XMPPReconnect alloc] init];
[self.xmppReconnect activate:self.xmppStream];
[self.xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];

And implement 'XMPPReconnect' delegate methods

- (void)xmppReconnect:(XMPPReconnect *)sender didDetectAccidentalDisconnect:(SCNetworkReachabilityFlags)connectionFlags
{
    NSLog(@"didDetectAccidentalDisconnect:%u",connectionFlags);
}
- (BOOL)xmppReconnect:(XMPPReconnect *)sender shouldAttemptAutoReconnect:(SCNetworkReachabilityFlags)reachabilityFlags
{
    NSLog(@"shouldAttemptAutoReconnect:%u",reachabilityFlags);
    return YES;
}
like image 51
Suhail kalathil Avatar answered Feb 14 '23 19:02

Suhail kalathil