OpenFire server connection to the XMPP iOS chat client

3,829 views
Skip to first unread message

obaid

unread,
Apr 15, 2012, 6:49:15 AM4/15/12
to XMPPFramework
I'm able to connect to the local server, and also the google talk and
display the buddies and chat on the iphone chat client but when I try
to connect to the openfire it doesn't connect

(void)xmppStreamXMPPStream *)sender didReceivePresenceXMPPPresence
*)presence {

// a buddy went offline/online

NSString *presenceType = [presence type]; // online/offline
NSString *myUsername = [[sender myJID] user];
NSString *presenceFromUser = [[presence from] user];

if (![presenceFromUser isEqualToString:myUsername]) {

if ([presenceType isEqualToString:@"available"]) {

[_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@",
presenceFromUser, @"50.18.175.235"]];

} else if ([presenceType isEqualToString:@"unavailable"]) {

[_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@",
presenceFromUser, @"50.18.175.235"]];

}

}
}

I was setting the local server as obaid-macbook.local and google talk
as m.google.com in the place of "50.18.175.235" in the above code,
however I'm unable to connect to the openfire server that
50.18.175.235.

Jonathan Siao

unread,
Apr 15, 2012, 5:13:08 PM4/15/12
to xmppfr...@googlegroups.com
I use openfire and I managed to connect fine.


--
You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
To post to this group, send email to xmppfr...@googlegroups.com.
To unsubscribe from this group, send email to xmppframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xmppframework?hl=en.




--
Regards
Jonathan Siao

Hub King's Cross
34 York Way
London N1 9AB
fax: +44(0)2071128338
mobile: +44(0)7765031393
skype: Jonathan.siao


obaid jawad

unread,
Apr 16, 2012, 1:23:04 AM4/16/12
to xmppfr...@googlegroups.com
I see, that's great to hear, can I know what are the settings that are required to be done on the server side that should be compatible with the iOS, and also have you used the "Server name" in the server settings in the iOS code _chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@",presenceFromUser, @"Server"]]; ?

obaid

unread,
Apr 16, 2012, 2:44:02 AM4/16/12
to XMPPFramework
I see, that's great to hear, can I know what are the settings that are
required to be done on the server side that should be compatible with
the
iOS, and also have you used the "Server name" in the server settings
in the
iOS code _chatDelegate buddyWentOffline:[NSString
stringWithFormat:@"%@@%@",presenceFromUser,
@"Servername or IP"]]; ?

Pralea Danut

unread,
Apr 16, 2012, 4:47:05 AM4/16/12
to xmppfr...@googlegroups.com
Those are just to display the name for the user in the contacts list.
What you need to do is set the hostName property. Optionally the host port.

[xmppStream setHostName:kHostName];
[xmppStream setHostPort:5222];

where kHostName is a constant string defined earlier. Like 

#define kHostName @"XX.XXX.XX.XXX" (replace X with your server's ip)

obaid jawad

unread,
Apr 16, 2012, 6:06:26 AM4/16/12
to xmppfr...@googlegroups.com
Thank you for your valuable response, but yes I tried with this and also debug it but I'm not able to connect to the server, In other I have installed one packet tracer to trace whether the packets are sent to the server IP or not, so I have seen in it that it is getting response it initates as destination to the server, However I'm not visible to other and also I'm not able to view my buddy list.

To debug it I have put the breakpoints at
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender {
   
    // authentication successful
    [self goOnline];
   
}

and on

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {
    }

but the program doesn't even come to this methods.

I'd like to provide you with my server IP and with the username and password for one of the Openfire user, and check it in your code whehter it is able to connect it or not. If you can please help me Thank you so much.

obaid jawad

unread,
Apr 16, 2012, 6:09:54 AM4/16/12
to xmppfr...@googlegroups.com
I forgot to mention as I debug it I have also put the breakpoints on this method and the compiler comes to this method after I press login
- (void)xmppStreamDidConnect:(XMPPStream *)sender {
   
    // connection to the server successful
    isOpen = YES;
//    NSLog(@"hi");
    NSError *error = nil;
    [[self xmppStream] authenticateWithPassword:password error:&error];

obaid jawad

unread,
Apr 16, 2012, 8:08:28 AM4/16/12
to xmppfr...@googlegroups.com
Hi, An update I have run wireshard on my mac to trace the data packets are sent to the server side on not, that is OpenFire server and I see that the iOS chat client sdk, is able to connect to the Openfire server, but it could not authenticate the user. Here is the description in the image, It is the screen shot for it.
http://i41.tinypic.com/344xdfp.png

obaid jawad

unread,
Apr 16, 2012, 8:47:01 AM4/16/12
to xmppfr...@googlegroups.com
Update to this issue, I have checked to login with the OSX jabber chat client from Adium, and when I add account and whenever I tries to login it as me for to accept the certificate, then only it gives me permission to get visible, Could that be a problem of certificate?
I have taken the screenshot for this issue, please have a look at this link

http://i39.tinypic.com/feg9z8.png

Thank you, please help me out to solve this issue.

obaid jawad

unread,
Apr 17, 2012, 3:58:44 AM4/17/12
to xmppfr...@googlegroups.com
Guys!! I'd like to inform you that the issue is now solved, it was the problem with the server name and the hostname on the Openfire application on server side admin panel. It then verified and get connected.

avaan

unread,
Aug 14, 2013, 4:21:25 AM8/14/13
to xmppfr...@googlegroups.com
Hi Obaid,

I am facing the same problem.
I am not able to get login into the OpenFire server and also not able to get currently active buddy list.

I tried to fix this issue but without any success.
Can you please let me know how you have fixed this issue?  It will be helpful if you provide the source code also.

Thanks,
Avaan

Obaid Shaik

unread,
Aug 14, 2013, 4:30:35 AM8/14/13
to xmppfr...@googlegroups.com
As I told in my last post that
'Guys!! I'd like to inform you that the issue is now solved, it was the problem with the server name and the hostname on the Openfire application on server side admin panel. It then verified and get connected.'

did you checked this?


To unsubscribe from this group and stop receiving emails from it, send an email to xmppframewor...@googlegroups.com.

To post to this group, send email to xmppfr...@googlegroups.com.

avaan

unread,
Aug 14, 2013, 5:15:17 AM8/14/13
to xmppfr...@googlegroups.com
Hi Obaid,

Yes I checked your comment "server name and the hostname on the Openfire application on server side admin panel".
But I did not understand it correctly. Do I need to make the host name same as Server Name?

Below is my current server name and host name.

The server name is :- comspots2.no-ip.biz
HostName:- openfire-test

Please confirm.

Avaan.

Obaid Shaik

unread,
Aug 14, 2013, 5:25:51 AM8/14/13
to xmppfr...@googlegroups.com
remove your hostname and put it empty and then test the application


avaan

unread,
Aug 14, 2013, 5:50:23 AM8/14/13
to xmppfr...@googlegroups.com
Thanks for your reply.
But I could not able to remove the Hostname in Openfire server. As it is taken the system name by default while installing open fire.

Do I need to re-instal the open fire again? or is their any way I can make Hostname empty in source code itself?

Avaan.

Obaid Shaik

unread,
Aug 14, 2013, 6:22:32 AM8/14/13
to xmppfr...@googlegroups.com
Yeah I meant to change the hostname XMPP chat client source code.(Xcode).


avaan

unread,
Aug 14, 2013, 7:00:11 AM8/14/13
to xmppfr...@googlegroups.com
Thanks for the info.
Can you please share with me the source code snippet for the same.

Please find below my changes,

- (void)setupStream {

xmppStream = [[[XMPPStream alloc] init]autorelease];

    [xmppStream setHostName:@" "];

    [xmppStream setHostPort:5222];

[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

}



(void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {

NSString *presenceType = [presence type]; // online/offline

NSString *myUsername = [[sender myJID] user];

NSString *presenceFromUser = [[presence from] user];

if (![presenceFromUser isEqualToString:myUsername]) {

if ([presenceType isEqualToString:@"available"]) {

[_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @" "]];

} else if ([presenceType isEqualToString:@"unavailable"]) {

[_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @" "]];

}


But still it is not working.

Obaid Shaik

unread,
Aug 14, 2013, 7:12:08 AM8/14/13
to xmppfr...@googlegroups.com
where is the code that you have put your server name that is comspots2.no-ip.biz


Message has been deleted

Obaid Shaik

unread,
Aug 14, 2013, 7:48:16 AM8/14/13
to xmppfr...@googlegroups.com
Did you checked it?

avaan

unread,
Aug 14, 2013, 8:11:44 AM8/14/13
to xmppfr...@googlegroups.com
hi,


And I have initially has used my server name in below code,

if ([presenceType isEqualToString:@"available"]) {

[_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"comspots2.no-ip.biz "]];

else if ([presenceType isEqualToString:@"unavailable"]) {

[_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"comspots2.no-ip.biz "]];

}


But still it did not worked for me.


If you have the sample code please share with me. I am struggling a lot to connect to OpenFire server :(

avaan

unread,
Aug 14, 2013, 11:40:32 AM8/14/13
to xmppfr...@googlegroups.com
Hi,

Now I am able to connect to server. And able to recive msgs from other users.
But not able to see active users in my phone and not able display the msgs recived.

Obaid Shaik

unread,
Aug 14, 2013, 2:37:40 PM8/14/13
to xmppfr...@googlegroups.com
At first i want to tell you that you can use robbiehanson code i would
recommend this to you.. Because he updates the code time to time and
supportive

On 8/14/13, avaan <shan...@gmail.com> wrote:
> hi,
>
> I am using the code in link
> 'https://github.com/funkyboy/Building-a-Jabber-client-for-iOS'.
>
> And I have initially has used my server name in below code,
>
> if ([presenceType isEqualToString:@"available"]) {
>
> [_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@",
> presenceFromUser, @"comspots2.no-ip.biz "]];
>
> } else if ([presenceType isEqualToString:@"unavailable"]) {
>
> [_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@",
> presenceFromUser, @"comspots2.no-ip.biz "]];
>
> }
>
>
> But still it did not worked for me.
>
>
> If you have the sample code please share with me. I am struggling a lot to
> connect to OpenFire server :(
>
> On Wednesday, August 14, 2013 2:48:16 PM UTC+3, obaid wrote:
>>
>> Did you checked it?
>>
>>
>> On Wed, Aug 14, 2013 at 2:12 PM, Obaid Shaik
>> <blue...@gmail.com<javascript:>
>> > wrote:
>>
>>> where is the code that you have put your server name that is
>>> comspots2.no-ip.biz
>>>
>>>
>>> On Wed, Aug 14, 2013 at 2:00 PM, avaan <shan...@gmail.com
>>> <javascript:>>wrote:
>>>>>>>>>>>> http://i39.tinypic.com/feg9z8.********png<http://i39.tinypic.com/feg9z8.png>
>>>>>>>>>>>>
>>>>>>>>>>>> Thank you, please help me out to solve this issue.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Apr 16, 2012 at 3:08 PM, obaid jawad
>>>>>>>>>>>> <blue...@gmail.com>wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi, An update I have run wireshard on my mac to trace the data
>>>>>>>>>>>>>
>>>>>>>>>>>>> packets are sent to the server side on not, that is OpenFire
>>>>>>>>>>>>> server and I
>>>>>>>>>>>>> see that the iOS chat client sdk, is able to connect to the
>>>>>>>>>>>>> Openfire
>>>>>>>>>>>>> server, but it could not authenticate the user. Here is the
>>>>>>>>>>>>> description in
>>>>>>>>>>>>> the image, It is the screen shot for it.
>>>>>>>>>>>>> http://i41.tinypic.com/**344xdfp******.png<http://i41.tinypic.com/344xdfp.png>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Mon, Apr 16, 2012 at 1:09 PM, obaid jawad
>>>>>>>>>>>>> <blue...@gmail.com
>>>>>>>>>>>>> > wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> I forgot to mention as I debug it I have also put the
>>>>>>>>>>>>>> breakpoints on this method and the compiler comes to this
>>>>>>>>>>>>>> method after I
>>>>>>>>>>>>>> press login
>>>>>>>>>>>>>> - (void)xmppStreamDidConnect:(**XM******PPStream *)sender {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> // connection to the server successful
>>>>>>>>>>>>>> isOpen = YES;
>>>>>>>>>>>>>> // NSLog(@"hi");
>>>>>>>>>>>>>> NSError *error = nil;
>>>>>>>>>>>>>> [[self xmppStream]
>>>>>>>>>>>>>> authenticateWithPassword:**passw******ord
>>>>>>>>>>>>>> error:&error];
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Mon, Apr 16, 2012 at 1:06 PM, obaid jawad <
>>>>>>>>>>>>>> blue...@gmail.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thank you for your valuable response, but yes I tried with
>>>>>>>>>>>>>>> this and also debug it but I'm not able to connect to the
>>>>>>>>>>>>>>> server, In other
>>>>>>>>>>>>>>> I have installed one packet tracer to trace whether the
>>>>>>>>>>>>>>> packets are sent to
>>>>>>>>>>>>>>> the server IP or not, so I have seen in it that it is getting
>>>>>>>>>>>>>>> response it
>>>>>>>>>>>>>>> initates as destination to the server, However I'm not
>>>>>>>>>>>>>>> visible to other and
>>>>>>>>>>>>>>> also I'm not able to view my buddy list.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> To debug it I have put the breakpoints at
>>>>>>>>>>>>>>> - (void)**xmppStreamDidAuthenticat******e:(**XMPPStream
>>>>>>>>>>>>>>> *)sender {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> // authentication successful
>>>>>>>>>>>>>>> [self goOnline];
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> and on
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> - (void)xmppStream:(XMPPStream *)sender
>>>>>>>>>>>>>>> didReceivePresence:(*
>>>>>>>>>>>>>>> *XMPPPresen******ce *)presence {
>>>>>>>>>>>>>>>> isEqualToString:@"unavailable"*****
>>>>>>>>>>>>>>>> ***]) {
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> [_chatDelegate buddyWentOffline:[NSString
>>>>>>>>>>>>>>>> stringWithFormat:@"%@@%@",
>>>>>>>>>>>>>>>> presenceFromUser, @"50.18.175.235"]];
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I was setting the local server as obaid-macbook.local and
>>>>>>>>>>>>>>>> google talk
>>>>>>>>>>>>>>>> as m.google.com in the place of "50.18.175.235" in the
>>>>>>>>>>>>>>>> above code,
>>>>>>>>>>>>>>>> however I'm unable to connect to the openfire server that
>>>>>>>>>>>>>>>> 50.18.175.235.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Google Groups "XMPPFramework" group.
>>>>>>>>>>>>>>>> To post to this group, send email to
>>>>>>>>>>>>>>>> xmppfr...@googlegroups.com**.
>>>>>>>>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>>>>>>>>> xmppframewor...@**googlegroups.**c****om.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> For more options, visit this group at
>>>>>>>>>>>>>>>> http://groups.google.com/**group******/xmppframework?hl=en<http://groups.google.com/group/xmppframework?hl=en>
>>>>>>>>>>>>>>>> .
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Google Groups "XMPPFramework" group.
>>>>>>>>>>>>>>>> To post to this group, send email to
>>>>>>>>>>>>>>>> xmppfr...@googlegroups.com**.
>>>>>>>>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>>>>>>>>> xmppframewor...@**googlegroups.**c****om.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> For more options, visit this group at
>>>>>>>>>>>>>>>> http://groups.google.com/**group******/xmppframework?hl=en<http://groups.google.com/group/xmppframework?hl=en>
>>>>>>>>>>>>>>>> .
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>>>
>>>>>>>>>> Groups "XMPPFramework" group.
>>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>>>
>>>>>>>>>> send an email to xmppframewor...@**googlegroups.**c**om.
>>>>>>>>>>
>>>>>>>>>> To post to this group, send email to
>>>>>>>>>> xmppfr...@googlegroups.com**.
>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>> https://groups.google.com/d/**ms****gid/xmppframework/6c1b47f7-**
>>>>>>>>>> bde****f-4cb9-a253-2ed1d8dc007c%**40goo****glegroups.com<https://groups.google.com/d/msgid/xmppframework/6c1b47f7-bdef-4cb9-a253-2ed1d8dc007c%40googlegroups.com>
>>>>>>>>>> .
>>>>>>>>>> For more options, visit https://groups.google.com/**grou****
>>>>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "XMPPFramework" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to xmppframewor...@**googlegroups.**com.
>>>>>>>> To post to this group, send email to xmppfr...@googlegroups.com**.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/**ms**gid/xmppframework/4f048a10-**e4c**
>>>>>>>> 6-40d1-99f2-d36635b29cea%**40goo**glegroups.com<https://groups.google.com/d/msgid/xmppframework/4f048a10-e4c6-40d1-99f2-d36635b29cea%40googlegroups.com>
>>>>>>>> .
>>>>>>>>
>>>>>>>> For more options, visit
>>>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>>>> .
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "XMPPFramework" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>>>
>>>>>> an email to xmppframewor...@**googlegroups.com.
>>>>>> To post to this group, send email to xmppfr...@googlegroups.com**.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/*
>>>>>> *msgid/xmppframework/ed0cd302-**c9bd-4b15-b0f7-0a70cfb14127%**
>>>>>> 40googlegroups.com<https://groups.google.com/d/msgid/xmppframework/ed0cd302-c9bd-4b15-b0f7-0a70cfb14127%40googlegroups.com>
>>>>>> .
>>>>>>
>>>>>> For more options, visit
>>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "XMPPFramework" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to xmppframewor...@googlegroups.com <javascript:>.
>>>> To post to this group, send email to
>>>> xmppfr...@googlegroups.com<javascript:>
>>>> .
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/xmppframework/293386ef-7fb4-4401-b6b2-eb2250d14410%40googlegroups.com
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "XMPPFramework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to xmppframewor...@googlegroups.com.
> To post to this group, send email to xmppfr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/xmppframework/b2ecc5de-17ee-40da-8ed0-3f1045af299e%40googlegroups.com.

avaan

unread,
Aug 15, 2013, 2:45:39 AM8/15/13
to xmppfr...@googlegroups.com
Obaid,
Thanks for your help.
I did not find any sample code in robbiehanson code for simple chat ios app.
if you know one share the link with me please.

Avaan

Marcelo Santoro

unread,
Aug 15, 2013, 9:24:08 AM8/15/13
to xmppfr...@googlegroups.com
Hi Avaan… i am building a chat app too… 

i am using this sample to make my chatView


Hope help you.

See ya.

Best Regards from Brazil :)

Pratik Gandhi

unread,
Jan 10, 2014, 4:31:55 AM1/10/14
to xmppfr...@googlegroups.com
Hi ,
    Not about to connect to server from ios client... Plz reply me on prati...@gmail.com

Subramani K

unread,
Aug 10, 2016, 6:33:54 AM8/10/16
to XMPPFramework
Hi obaid , now i'm trying chat app in objective c but still i can't get solution for how to connect to the local server, and display the buddies and chat on the iphone chat client

Thank you obaid
Reply all
Reply to author
Forward
0 new messages