繁体   English   中英

无法使用XMPPFramework在Ejabberd中注册用户

[英]Unable to register an user in Ejabberd using XMPPFramework

我正在使用XMPPFramework编写iOS客户端。 我无法重新分配用户。 我已经配置了ejabberd服务器,它已经启动并正在运行。 我没有任何问题。 我可以从Ejabberd的门户网站注册用户。 但是,当我尝试从iOS客户端注册用户时,就会出现问题。 服务器日志如下

=INFO REPORT==== 2014-04-26 12:06:43 ===
I(<0.380.0>:ejabberd_listener:281) : (#Port<0.3865>) Accepted connection {{211,28,44,250},49742} -> {{172,31,0,235},5222}

=INFO REPORT==== 2014-04-26 12:06:44 ===
I(<0.424.0>:ejabberd_c2s:802) : ({socket_state,gen_tcp,#Port<0.3865>,<0.423.0>}) Failed authentication for xcc@localhost

身份验证方法是odbc。 由于我使用mysql进行数据和消息存储。

我从客户端捕获的日志如下

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

重要的一行在下面

2014-04-25 20:46:49:865 iPhoneXMPP [1971:4953] RECV:

我正在使用registerwithpassword方法,我真的很困惑为什么我无法注册。 我相信auth_method仅在尝试登录时才会起作用,因为它需要某种身份验证机制才能登录。 但是我只是在这里注册。 为什么我无法注册。 我相信主机名不是问题,因为我收到一条日志行,提示“ @localhost身份验证失败”

这意味着我正在打服务器。 ejabberd.cfg文件中缺少我阻止的内容吗?

请注意:另外,我尝试将authmethod作为内部方法(尽管在帮助中提到它与mnesia有关-内置数据库,并且我正在使用mysql),仍然遇到相同的问题,并且我相信客户端无法注册用户由于某些连接设置。

问题出在客户端还是服务器端。 请指导我。 谢谢你的时间。

为了使注册生效,您需要确保流已连接。 我在下面显示了如何注册用户的示例。

- (IBAction)signUpButtonPressed:(UIButton *)sender {
   // when the sign up button is pressed, set the JID for the xmpp stream
    [self.xmppStream setMyJID:[XMPPJID jidWithString:jid]];
     // check that the stream is not disconnected
     if([self.xmppStream isDisconnected]){
          // stream is not connected, attempt to connect
         if (![self.xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error]) {
             NSlog(@"Error connecting: %@", error);
          }
          // after stream connects, call [self beginRegistration] in xmppStreamDidConnect delegate method
     } else {
          [self beginRegistration];
     }
 }    

-(void) beginRegistration {
  // check if inband registration is supported
   if (self.xmppStream.supportsInBandRegistration) {
       if (![self.xmppStream registerWithPassword:password error:&error]) {
             NSlog(@"Registration error: %@", error);
       }
   } else {
       NSlog(@"Inband registration is not supported");
   }
}

要检查注册是否成功,请使用xmppStreamDidRegister:(XMPPStream *)senderxmppStream:(XMPPStream *)sender didNotRegister:(NSXMLElement *)error委托方法。

让我知道是否有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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