OS X ejabberd,XMPPFramework的新用户注册

时间:2016-08-29 07:03:06

标签: ios macos xmpp ejabberd xmppframework

我是ejabberd的新手。我想通过我的iOS应用程序在服务器上添加新用户。 I tried with many code是从谷歌中找到的,但没有人可以解决我的问题。

我将模块设置为http://localhost:5280/admin/server/localhost/node/ejabberd@localhost/modules/

enter image description here 要启用mod_register,还要更改ejabberd.yml文件夹中的etc/ejabberd文件。

enter image description here

我的收听的ejabberd @ localhost

端口

enter image description here

我使用下面的代码注册用户。

NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"jabber:iq:register"];
        [query addChild:[NSXMLElement elementWithName:@"username" stringValue:@"syam"]];
        [query addChild:[NSXMLElement elementWithName:@"password" stringValue:@"Vrin@123"]];
        NSXMLElement *iq = [NSXMLElement elementWithName:@"iq"];
        [iq addAttributeWithName:@"type" stringValue:@"set"];
        [iq addAttributeWithName:@"id" stringValue:@"reg2"];
        [iq addChild:query];
        [APP_DELEGATE.xmppStream sendElement:iq];

        [APP_DELEGATE.xmppStream setHostName:@"0.0.0.0"];
        [APP_DELEGATE.xmppStream setHostPort:5222];
        NSError *error;
        if (![APP_DELEGATE.xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting"
                                                                message:@"See console for error details."
                                                               delegate:nil
                                                      cancelButtonTitle:@"Ok"
                                                      otherButtonTitles:nil];
            [alertView show];
        }

但未获得成功并发生在错误消息下方。

<iq xmlns="jabber:client" from="himanshu@localhost" to="himanshu@localhost/15505992182228745748626" type="error" id="reg2"><query xmlns="jabber:iq:register"><username>syam</username><password>Vrin@123</password></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">No module is handling this query</text></error></iq>

请帮我解决我的问题。

1 个答案:

答案 0 :(得分:1)

access: register表示 - 只有已经注册的用户才能访问mod_register(例如,更改密码)。您需要access: all才能注册。当服务器为公共网络打开时,不要忘记用CAPTCHA保护注册(在这种情况下,XMPPFramework中的简单注册实现是不够的)

还不清楚是否为您的虚拟主机启用了mod_register,请检查配置的modules:块中的mod_register状态