10

I'm new for ejabberd. I want to add new user on server through my iOS App. I tried with many code that was find out from the Google but no one can solve my issue.

I set module to http://localhost:5280/admin/server/localhost/node/ejabberd@localhost/modules/

enter image description here For enable mod_register also change ejabberd.yml file from etc/ejabberd folder.

enter image description here

And my Listened Ports at ejabberd@localhost

enter image description here

And I used below code for register user.

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];
        }

But didn't get success and occurred below error message.

<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>

Please help me to solve my issue.

iPatel
  • 46,010
  • 16
  • 115
  • 137

1 Answers1

1

access: register means - only already registered users are able to access mod_register (to change password, for example). You need to have access: all to allow registration. And do not forget to protect registration with CAPTCHA when server will be opened for public network (and in this case that simple registration implementation in XMPPFramework will not enough)

Also it's not clear is mod_register enabled for your virtualhost, check mod_register presence in modules: block of your configuration

vitalyster
  • 4,980
  • 3
  • 19
  • 27
  • Thanks for your answer, I already done "access: all" but did not get success and about CAPTCHA its optional but as per your suggestion i will do it. – iPatel Sep 01 '16 at 13:27
  • Updated answer to mention modules config – vitalyster Sep 01 '16 at 13:38
  • No there is no mod_register in modules: so where I'm going wrong? can you tell me because my .yml file configuration is correct. – iPatel Sep 02 '16 at 04:08