iOS 与 XMPP 的连接失败
iOS Connection With XMPP Failed
我正在 iOS 使用 xmpp 服务器开发聊天应用程序。当我尝试连接到服务器时,它毫无例外地返回 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];
}
关注 this link
中给出的连接 class
连接到服务器 returns 仅当您指定错误 HostName
、HostPort
或 JID
.
时才为“0”
还有一件事你不需要明确地调用 xmppStreamDidConnect
它将作为来自 XMPPFramework
的委托被调用。
我正在 iOS 使用 xmpp 服务器开发聊天应用程序。当我尝试连接到服务器时,它毫无例外地返回 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];
}
关注 this link
中给出的连接 class 连接到服务器 returns 仅当您指定错误 HostName
、HostPort
或 JID
.
还有一件事你不需要明确地调用 xmppStreamDidConnect
它将作为来自 XMPPFramework
的委托被调用。