Unable to connect XMPPFramework to Openfire server in iOS

不羁的心 提交于 2019-12-02 00:29:34

A host of possibilities.

Try adding break points at xmppStreamDidConnect and xmppStreamDidAuthenticate.

If xmppStreamDidConnect isn't reached, the connection is not established; you've to rectify your hostName.

If xmppStreamDidAuthenticate isn't reached, the user is not authenticated; you've to rectify your credentials i.e. username and/or password.

One common mistake is omitting of @domainname at the back of username i.e. username@domainname e.g. keithoys@openfireserver where domain name is openfireserver.

Yaron Reinharts

Hope this still relevant, if not, hopefully it will help others. There are some issues with your code:

  1. I don't see the call to connect, you should add something like this:

    NSError *error = nil;
    if (![_xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) { 
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting"
                                                            message:@"Msg"
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];       
    }
    
  2. Most of the XMPP API is asynchronous.
    You have to set the stream delegate in order to receive events. Check out XMPPStreamDelegate and XMPPStream#addDelegate

If you don't want to go through the code yourself XMPPStream.h , you can implement all methods of XMPPStreamDelegate and log the events. This will help you understand how the framework works.

Hope this helps, Yaron

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!