【问题标题】:How to setup my xmpp server with ejabberd in iOS如何在 iOS 中使用 ejabberd 设置我的 xmpp 服务器
【发布时间】:2015-11-22 15:03:36
【问题描述】:
  • ejabberd 我安装了最新的 ejabberd 并按照建议逐步设置主机名,如 jyhu 使用 test@jyhu

  • xmpp我正在从github下载最新的XMPPFramework。

  • iOS 设置项目如下:

    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]);
      }
      

然后设置一些相关的委托方法。

当我运行我的项目时,ejabberd 日志显示如下

2015-08-28 10:45:29.890 [信息] @ejabberd_listener:accept:299 (#Port) 接受连接 127.0.0.1:62419 -> 127.0.0.1:5280 2015-08-28 10:45:29.890 [信息] @ejabberd_http:init:157 开始:{gen_tcp,#Port}

代表会去:

  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

但是最重要的方法- (void)xmppStreamDidConnect:(XMPPStream *)sender永远不会被执行。

【问题讨论】:

    标签: ios xmpp ejabberd


    【解决方案1】:

    您正在尝试连接端口 5280,该端口为 XMPP Bosh 和 Websocket 传输保留。您可能想要连接到标准 XMPP 端口,即 5222。

    【讨论】:

      猜你喜欢
      • 2018-04-27
      • 2012-07-18
      • 2018-06-05
      • 2015-11-05
      • 2015-10-04
      • 2020-06-28
      • 2016-09-15
      • 2014-11-16
      • 2016-02-09
      相关资源
      最近更新 更多