iOS连接XMPP失败

时间:2015-09-08 07:19:14

标签: ios xmpp

我正在使用xmpp服务器在iOS中开发聊天应用。当我尝试连接到服务器时,它返回0没有任何异常。据我所知,所有服务器凭据都是真实的。我尝试了很多次但是没有找到任何富有成效的帮助。请给我一个方向,我应该怎么做。这是下面的代码。

xmppStream = [[XMPPStream alloc] init];

//    [self setupStream];
    NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
    [xmppStream sendElement:presence];

    [xmppStream setMyJID:[XMPPJID jidWithString:@"app.com"]];

    [xmppStream setHostName:@"appname.com"];
    [xmppStream  setHostPort:5222];

    NSError *error2;
    if ([xmppStream connect:&error2])
    {
        NSLog(@"Connected to XMPP.");
    }
    else
    {
        NSLog(@"Error connecting to XMPP: %@",[error2 localizedDescription]);
    }
    [self xmppStreamDidConnect:xmppStream];

//method is
- (void)setupStream {
    NSLog(@"setupStream in delegate");
    xmppStream = [[XMPPStream alloc] init];
    [xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
    self.xmppStream.hostName = @"appname.com";
    self.xmppStream.hostPort = (port);
    [self connect];
}

0 个答案:

没有答案