注册模块的错误解决
来源:互联网 发布:cad工程量计算软件 编辑:程序博客网 时间:2024/05/27 20:36
今天在弄注册模块的时候发现注册不了,,为了方便直接用了openfire。。然后问题就来 了,return错误码为4------RegistrationBadRequest;百度了下,找到解决的办法如下:
对于GLOOX自带的注册例子不能正常注册的问题有人在邮件列表里提出来。一个哥们这样回答:
- Ok, I've found what the problem was
- In openFire server parameters, Anonymous Login => Disabled !!!
- Ok, I've found what the problem was
- In openFire server parameters, Anonymous Login => Disabled !!!
意思是要禁用openFire服务器里的选项”注册和登录“的”匿名登录“项。
笔者按此说明禁用该选项,果然注册成功。
这说明开始的注册失败是和匿名登录有关系的。我们来看一下引用registration_expmple例子登录失败时的XML流:
S->C:服务器返回给客户端支持的认证机制:
- <stream:features xmlns:stream='http://etherx.jabber.org/streams'><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns='http://jabber.org/features/compress'><method>zlib</method></compression><authxmlns='http://jabber.org/features/iq-auth'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
- <stream:features xmlns:stream='http://etherx.jabber.org/streams'><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns='http://jabber.org/features/compress'><method>zlib</method></compression><auth xmlns='http://jabber.org/features/iq-auth'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
从上面XML流中我们可以看到,默认openFire支持四种认证机制,分别是:DIGEST-MD5、PLAIN、ANONYMOUS、CRAM-MD5。然后我们看GLOOX客户端的响应流:
C->S:客户端返回选择的认证方式:
- <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>
- <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>
接下来的流程就是客户端”无耻“的选择了以匿名的方式登录了服务器,然后再发送注册请求,请求如下:
- <iq id='uid:4e69eccd:00006784' type='set' from='447e0585@zxl/447e0585' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</password><name>test2</name><email>163@gmail.com</email></query></iq>
- <iq id='uid:4e69eccd:00006784' type='set' from='447e0585@zxl/447e0585' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</password><name>test2</name><email>163@gmail.com</email></query></iq>
我们看到,IQ节里包含“form”属性,即客户端匿名身份标识。
注意,一个客户端已经以一个身份(由服务器临时分配的一个JID)登录,建立了会话,在服务器上我们会看到这个会话,并且服务器发送心跳一直维护这个会话。这种情况下,这个客户端再发送注册请求(另一个身份)建立与服务器的连接是不被允许的。具体请参考XEP-0077(In-Band Registration):我们关注这两段:
- If the entity cancels its registration with its "home" server (i.e., the server at which it has maintained its XMPP account), then the entity SHOULD NOT include a 'from' or 'to' address in the remove request the server SHOULD then return a <not-authorized/> stream error and terminate all active sessions for the entity. The server SHOULD perform the remove based on the bare JID <localpart@domain.tld> associated with the current session or connection over which it received the remove request. If the server is an instant messaging and presence server that conforms to XMPP IM [8], the server SHOULD also cancel all existing presence subscriptions related to that entity (as stored in the entity's roster).
- If the entity cancels its registration with a service other than its home server, its home server MUST stamp a 'from' address on the remove request, which in accordance with XMPP Core will be the entity's full JID <localpart@domain.tld/resource>. The service MUST perform the remove based on the bare JID <localpart@domain.tld> portion of the 'from' address.
- If the entity cancels its registration with its "home" server (i.e., the server at which it has maintained its XMPP account), then the entity SHOULD NOT include a 'from' or 'to' address in the remove request the server SHOULD then return a <not-authorized/> stream error and terminate all active sessions for the entity. The server SHOULD perform the remove based on the bare JID <localpart@domain.tld> associated with the current session or connection over which it received the remove request. If the server is an instant messaging and presence server that conforms to XMPP IM [8], the server SHOULD also cancel all existing presence subscriptions related to that entity (as stored in the entity's roster).
- If the entity cancels its registration with a service other than its home server, its home server MUST stamp a 'from' address on the remove request, which in accordance with XMPP Core will be the entity's full JID <localpart@domain.tld/resource>. The service MUST perform the remove based on the bare JID <localpart@domain.tld> portion of the 'from' address.
正常的注册流如下:
- <iq id='uid:4e69eccd:00003d6c' type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</password><name>test2</name><email>163@gmail.com</email></query></iq>
- <iq id='uid:4e69eccd:00003d6c' type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</pssword><name>test2</name><email>163@gmail.com</email></query></iq>
---------------------------
综上所述,解决方案如下:
一、关闭openFire的匿名登录功能。^_^……
二、禁止GLOOX匿名认证功能。
- file:client.cpp
- fun: int Client::getSaslMechs( Tag* tag )
- line:355
- 将355行注释掉即可。
- 354:if( tag->hasChildWithCData( mech, "ANONYMOUS" ) )
- 355 //mechs |= SaslMechAnonymous;
- file:client.cpp
- fun: int Client::getSaslMechs( Tag* tag )
- line:355
- 将355行注释掉即可。
- 354:if( tag->hasChildWithCData( mech, "ANONYMOUS" ) )
- 355 //mechs |= SaslMechAnonymous;
重新编译生成DLL即可。
三、手动设置GLOOX客户端SASL认证机制
在调用j->connect()之前设置SASL认证机制,比如设置为“DIGEST-MD5”
- j->setSASLMechanisms(SaslMechDigestMd5);
- j->setSASLMechanisms(SaslMechDigestMd5);
四、根据XEP-0077所述,即使其名登录,注册流只要不带“from”属性应该也可以。所以我们要处理发出的注册流,去除“from”属性重新发送注册流即可。
附原地址:
http://blog.csdn.net/abcpanpeng/article/details/7370974- 注册模块的错误解决
- 解决 “regsvr32 注册ocx 找不到指定的模块”的问题
- 解决Mod_wsgi模块的编译错误
- 解决tomcat报“未撤销注册的JDBC驱动”错误
- Redhat没有注册时yum安装的错误解决
- 系统错误:&H8007007E(-2147024770)。 找不到指定的模块。解决
- 模块对于 SAFESEH 映像是不安全的 错误解决
- 解决Django使用MySQL报模块找不到的错误
- 【解决】关于蓝牙模块串口设置总是错误的问题
- Android支付宝模块的ali64错误解决
- 关于Delphi2007 Remote Data Module模块无法注册的问题的解决
- 关于Delphi2007 Remote Data Module 模块无法注册的问题的解决
- Java做的注册模块
- linux 文件系统模块的注册
- 注册表单验证的模块
- 解决chrome提示没有注册类错误
- 解决 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节的错误
- 解决在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。
- linux中查看内存状态的命令、查看进程状态的命令
- 微控制器、RTOS与网络,嵌入式物联网开发平台解读
- Extjs 使用form上传文件,在IE8出现乱码,但是其他浏览器可以正常解读
- 原生类型的处理
- 实现core文件自动生成配置文件的方法
- 注册模块的错误解决
- Leetcode Single Number
- Android XML文件中引用资源的方法
- 【BZOJ3265】志愿者招募加强版 线性规划 单纯形法 对偶原理
- 几种开源TCPIP协议概述--LwIP,uIP,TinyTcp和uC/IP
- ActionBar(6)操作提供器ActionProvider及以ShareActionProvider演示
- java入门
- @Autowired
- js中如何实现继承