Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Not able to connect to openfire server using xmpp for ios chat #118

Open
rk28286 opened this Issue · 18 comments

6 participants

@rk28286

Hello,

I have downloaded the xmpp framework sample code and tried to login to openfire server for connecting with yahoo but i am not able to do so.

I have installed kraken plugin and enable the services also i did check the connection in openfire admin panel it passes the test. But when i try to connect in ios it does not even go to connect method.

It always show unable to connect to server check host name. But i could see anywhere to change the hostname.

Please any one let me know the settings to be done. Very much frustrated with this.

Appreciate your help.

Thanks,

Ronak

@ObjColumnist
Collaborator

It is a property on XMPPStream

xmppStream.hostname = @"example.com";
@rk28286

still not getting to connect...if you could help me with some snippet code i'll be thankful

@ObjColumnist
Collaborator

If you look at the iOS sample project, you would set the hostname before you call connect on the XMPPStream.

This is done in the connect method of iPhoneXMPPAppDelegate

@rk28286

do i need to change - (void)xmppStream:(XMPPStream *)sender willSecureWithSettings:(NSMutableDictionary *)settings
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

if (allowSelfSignedCertificates)
{
    [settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
}

if (allowSSLHostNameMismatch)
{
    [settings setObject:[NSNull null] forKey:(NSString *)kCFStreamSSLPeerName];
}
else
{
    // Google does things incorrectly (does not conform to RFC).
    // Because so many people ask questions about this (assume xmpp framework is broken),
    // I've explicitly added code that shows how other xmpp clients "do the right thing"
    // when connecting to a google server (gmail, or google apps for domains).

    NSString *expectedCertName = nil;

    NSString *serverDomain = xmppStream.hostName;
    NSString *virtualDomain = [xmppStream.myJID domain];

    if ([serverDomain isEqualToString:@"talk.google.com"])
    {
        if ([virtualDomain isEqualToString:@"gmail.com"])
        {
            expectedCertName = virtualDomain;
        }
        else
        {
            expectedCertName = serverDomain;
        }
    }
    else if (serverDomain == nil)
    {
        expectedCertName = virtualDomain;
    }
    else
    {
        expectedCertName = serverDomain;
    }

    if (expectedCertName)
    {
        [settings setObject:expectedCertName forKey:(NSString *)kCFStreamSSLPeerName];
    }
}

}

@ObjColumnist
Collaborator

Your connecting to your openfire server at this point, so you shouldn't need to.

That also means you need to be using your openfire credentials and not your yahoo credentials.

@rk28286

so how would i get the yahoo users of my account can you please guide me the steps

@ObjColumnist
Collaborator

Once you have authenticated with your openfire server you need to use the XMPPTransports module to authenticate with Yahoo.

Unfortunately I don't have any sample code as I haven't needed to do this with this version of the XMPPFramework.

@rk28286

i am getting 2012-10-26 17:16:43:931 iPhoneXMPP[3549:907] iPhoneXMPPAppDelegate: xmppStreamDidDisconnect:withError:
2012-10-26 17:16:43:958 iPhoneXMPP[3549:907] Unable to connect to server. Check xmppStream.hostName

i have used openfire credentials for login

@rk28286

can you please try for this i will compensate for this

@rajeshbeats

I am also getting the same error , can any one help ?

@TejeshwarGill

I am getting the same issue of Unable to connect to server. Check xmppStream.hostName.... Can anyone help ?

@williamoconnor

I am getting the error as well. It was working just fine when I used a local server, but now that I have a remote server, substituting the former "williams-macbook" with the ip address does not work

@vitalyster

@williamoconnor if "Server name" of your openfire instance is "williams-macbook", then you shouldn't replace it with ip, but still use "williams-macbook" as domain part of the user JID (e.g., if you have user1 account, then your JID is user1@williams-macbook) and IP you should place in the "hostname" field.

@williamoconnor

@vitalyster
Well we installed Openfire on a remote server, and the new instance gives me an ip address for the server name and host name. When I replace "williams-macbook", which was the server and host name for the instance running on my local machine, with that ip address, it has problems connecting.

It gives the ip address in the format: "ip-xxx-xx-xx-xxx". When I use this format, it is unable to connect, but when I just put the number in as xxx.xx.xx.xxx, the operation times out

@vitalyster

@williamoconnor your "server name" is not the same as "host name". Imagine google.com or github.com - they have single "server name" but multiple hostnames/ip addresses, which changes everytime you are connecting.

@williamoconnor

@vitalyster In the admin panel for Openfire, it gives the same "ip-xxx-xx-xx-xxx" as the Server Name and the Host Name. Is that not the information that I want? Also, when I use "ip-xxx-xx-xx-xxx" value given in the admin panel as the host name, it fails to connect, and when I use the xxx.xx.xx.xxx format, it tells me the operation timed out. I don't know if that information is meaningful

@vitalyster

@williamoconnor amazon ec2 internal domain names? You should have public domain name (and set it up as "server name" in the openfire admin panel) and public ip address (and use it as "hostname", until you set up DNS SRV).

@williamoconnor

Got it! For the purpose of anyone else who has the issue, my hostName is "ec2-xxx-x-xx-xx.us-west-2.compute.amazonaws.com" and serverName = "ip-xxx-xx-xx-xxx" @vitalyster thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.