OS X下ejabberd,使用XMPPFramework实现新用户注册

10

我是一个ejabberd的新手。我想通过我的iOS应用程序在服务器上添加新用户。 我尝试了许多从谷歌上找到的代码,但没有人能解决我的问题。

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

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

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">没有模块处理此查询</text></error></iq>

请帮我解决我的问题。

1个回答

1

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

此外,不清楚您的虚拟主机是否启用了 mod_register,请检查配置文件中的 modules: 块中是否存在 mod_register


谢谢您的回答,我已经尝试了“access: all”,但没有成功。关于验证码,虽然它是可选的,但根据您的建议,我会添加它。 - iPatel
更新答案以提及模块配置。 - vitalyster
没有在模块中找到mod_register,所以我错在哪里了?你能告诉我吗?因为我的.yml文件配置是正确的。 - iPatel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接