简体   繁体   中英

Unable to register a user from iOS Client to Ejabberd Server - XMPP

I made an EJabberd server up and running. I am writing a simple chat client in iOS where I try to register an user. But I am not able to register an user. I am sure the request is hitting the Ejabberd server.

The Log in server is below

=INFO REPORT==== 2014-04-25 10:46:51 ===
I(<0.381.0>:ejabberd_listener:281) : (#Port<0.3853>) Accepted connection {{211,28,44,250},52988} -> {{172,31,0,235},5222}

=INFO REPORT==== 2014-04-25 10:46:52 ===
I(<0.398.0>:ejabberd_c2s:802) : ({socket_state,gen_tcp,#Port<0.3853>,<0.397.0>}) Failed authentication for ioc1@localhost

在此处输入图片说明

Any idea how to do this? Is this related to authmethod?

This is what I have in ejabberd.cfg

{host_config, "localhost", [{auth_method, [anonymous]},
                                 {anonymous_protocol, sasl_anon}]}.

The following is the log from XCODE

2014-04-25 20:46:49:384 iPhoneXMPP[1971:90b] SEND: <auth       xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5"/>
 2014-04-25 20:46:49:620 iPhoneXMPP[1971:650b] RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9IjMzNzkzODUwOTEiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
 2014-04-25 20:46:49:621 iPhoneXMPP[1971:650b] SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImlvYzEiLHJlYWxtPSJsb2NhbGhvc3QiLG5vbmNlPSIzMzc5Mzg1MDkxIixjbm9uY2U9IkMzN0U0NjlBLTg0RUUtNEY3RS1CNTEzLTM5RUJFREU0NzQ3NCIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9sb2NhbGhvc3QiLHJlc3BvbnNlPTQzYTY5OTVlZmY2Y2UwNzA0YmJkNWM4OWZiNGU5ZDQ1LGNoYXJzZXQ9dXRmLTg=</response>
2014-04-25 20:46:49:865 iPhoneXMPP[1971:4953] RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
2014-04-25 20:46:49:865 iPhoneXMPP[1971:90b] iPhoneXMPPAppDelegate: xmppStream:didNotAuthenticate:
2014-04-25 20:46:49.865 iPhoneXMPP[1971:90b] num--680
2014-04-25 20:46:49.866 iPhoneXMPP[1971:90b] elements--(
"<username>ioc1@localhost</username>",
"<password>ioc</password>",
"<name>ioc1@localhost</name>",
"<accounttype>1</accounttype>",
"<devicetoken>680</devicetoken>",
"<email>ioc1@localhost</email>"
)

Any info will be very helpful for me. Not sure where I am going wrong Thanks and appreciate your help

Do you really want to register(create) a new (persistent) user, or log in to (previously created) existing account? Or you does not want to care and want anonymous temporary logins without persistent accounts? Your ejabberd now configured to accept anonymous logins, but you are trying to authenticate existing user. If you are using XMPPFramework and want to get temporary login, just use [xmppStream loginAnonymously:] and server will log you in with temporary ID.

But if you want to use persistent accounts database, you need to change auth_method to something else (check ejabberd documentation), create user (you can create it on the server side, or register new user from client, or use existing user's database from different application) and only then you can authenticate with given username and password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM