iOS XMPP框架XMPPStream未连接?

iOS XMPP框架XMPPStream未连接?,ios,objective-c,xmpp,xmppframework,Ios,Objective C,Xmpp,Xmppframework,我正在尝试使用iOS上的XMPPFramework连接到公共XMPP服务器。当应用程序加载到中时,我设置了连接 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

我正在尝试使用iOS上的XMPPFramework连接到公共XMPP服务器。当应用程序加载到中时,我设置了连接

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    // Set up XMPP stream

    self.xmppStream = [[XMPPStream alloc] init];
    [self.xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

    self.xmppStream.hostName = @"jabber.web.id";
    self.xmppStream.hostPort = 5222;

    [self connect];
在连接中:

- (void)connect {
    NSString *username = @"eric1234";
    self.password = @"test123";

    [self.xmppStream setMyJID:[XMPPJID jidWithString:username]];

    NSError *error = nil;
    if (![self.xmppStream oldSchoolSecureConnectWithTimeout:XMPPStreamTimeoutNone error:&error])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                            message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }

    NSLog(@"%hhd", [self.xmppStream isConnected]);
}
然后是我的委托方法:

- (void)xmppStreamDidConnect:(XMPPStream *)sender {
    NSError *error = nil;
    if (![self.xmppStream authenticateWithPassword:self.password error:&error]) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                            message:[NSString stringWithFormat:@"Can't authenticate %@", [error localizedDescription]]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }
    [self.xmppStream sendElement:[XMPPPresence presence]];
}

从未调用xmppStreamDidConnect。我不知道为什么,我已经使用服务器上的桌面XMPP客户端在jabber.web.id上成功注册了eric1234。有什么想法吗?

我通过改变:

 NSString *username = @"eric1234@jabber.web.id";
9创建正确的JID: 所以,在上面的问题中

NSString *username = @"eric1234@domain_name";     (domain name may be diff. than hostname.)

我尝试了你的代码,无论我做什么,我似乎都没有得到任何错误。这对我没用。这是我的问题,这该死的东西根本不会说话。