简体   繁体   中英

How to setup my xmpp server with ejabberd in iOS

  • ejabberd I was installed the newest ejabberd with the suggestion step by step and set the host name like jyhu using like test@jyhu .

  • xmpp I was download the latest XMPPFramework from github .

  • iOS Setup the project fowllowing :

    1. init xmppStream

        self.xmppStream = [[XMPPStream alloc] init]; [self.xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()]; [self.xmppStream setHostName:@"127.0.0.1"]; [self.xmppStream setHostPort:5280]; 
    2. setup JID

       [self.xmppStream setMyJID:[XMPPJID jidWithString:self.userName]]; 
    3. connect

       if (![self.xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) { NSLog(@"%@", [error userInfo]); } 

Then setup some releated delegate methods .

When I run my project, the ejabberd log shown like

2015-08-28 10:45:29.890 [info] <0.436.0>@ejabberd_listener:accept:299 (#Port<0.3800>) Accepted connection 127.0.0.1:62419 -> 127.0.0.1:5280 2015-08-28 10:45:29.890 [info] <0.442.0>@ejabberd_http:init:157 started: {gen_tcp,#Port<0.3800>}

And the delegate will going :

  1. - (void)xmppStreamWillConnect:(XMPPStream *)sender

  2. - (void)xmppStream:(XMPPStream *)sender socketDidConnect:(GCDAsyncSocket *)socket

  3. - (void)xmppStreamDidStartNegotiation:(XMPPStream *)sender

  4. - (void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error

But the most important method - (void)xmppStreamDidConnect:(XMPPStream *)sender will never be executed.

You are trying to connect on port 5280, which is reserved for XMPP Bosh and Websocket transport. You likely wants to connect instead on the standard XMPP port, which is 5222.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM