1
votes

Problem : I am creating an iOS chat app using the XMPPFramework and an Openfire Server. However, I cannot connect to the server. I can however log in with GTalk or Facebook accounts. Furthermore, I can log in to the account on my own server using another Jabber client such as Spark.

Code : The base of my code is from the following tutorial : http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/

Here is where it connects :

- (void)setupStream {
    xmppStream = [[XMPPStream alloc] init];
    [xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
}

- (BOOL)connect {
    [self setupStream];

    NSString *jabberID = [[NSUserDefaults standardUserDefaults] stringForKey:@"userID"];
    NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];

    if (![xmppStream isDisconnected]) {
        return YES;
    }

    if (jabberID == nil || myPassword == nil) { 
        return NO;
    }

    [xmppStream setMyJID:[XMPPJID jidWithString:jabberID]];
    password = myPassword;

    NSError *error = nil;
    if (![xmppStream connect:&error])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" 
                                                            message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]  
                                                           delegate:nil 
                                                  cancelButtonTitle:@"Ok" 
                                                  otherButtonTitles:nil];
        [alertView show];
        [alertView release];

        return NO;
    }

    return YES;
}

Update 19 March : NSError is never populated so it was difficult to see what the error was. However, I have debugged through the code, and found an error in QueryRecordCallback of XMPPSRVResolver. The error code is -65554. After a google for this, I have discovered this ...

kDNSServiceErr_NoSuchRecord = -65554,

However, I am still unsure how to resolve this 'NoSuchRecord' issue. Furthermore, the logging on the OpenFire Server implies that we are not even getting to the OpenFire Server.

1

1 Answers

3
votes

The problem is likely to be your Openfire server not being on a public domain. Assuming your Openfire server is running on a private LAN server, the global DNS records will not be able to point to it.

If you have access to a publicly accessible domain, try putting the Openfire server on the machine that serves this IP.

From reading the documentation for XMPPFramework, this shouldn't cause a problem, but it did with me!