gloox 连接 openfire 使用笔记 --openfire 配置

============================================================
博文原创,转载请声明出处
电子咖啡(原id蓝岩)
============================================================
下载最新版的openfire,点击文件安装,安装成功那个。

启动方法:

打开系统偏好设置,在其他中找到openfire,点击,会提示“需要重新启动偏好设置”,点击确认,进入openfire界面。左侧显示openfire的运行状况,点击右侧的按钮,会打开web页面来配置openfire的相关信息。


初次登陆,会有初始化设置页面,直接点击“continute”到最后,到最后,设置系统管理密码,用户名默认是“admin”,我们需要设置密码。另外,openfire自带有数据库,如果我们对数据库要求不高(同时在线不超过100人),则可以用默认的,当然,我们也可以使用其他数据库。

设置完成,进入系统主界面。如下图:

gloox 连接 openfire 使用笔记 --openfire 配置_第1张图片

其中 servername 使我们稍后用gloox连接的主机名,默认是本机名字,当然我们也可以修改成为其他名字,但注意,这个servername和主机名最好一致,否则再gloox登陆时候可能连接不上。

系统主机名可以再“系统偏好设置”的“共享”中设置。servername可以再下面的“edit properties”按钮的新页面进行设置。

在“server setting”-》“registration & login”-》“annoymous login” 设置为disable,否则会出现登陆不上的问题。


-------------------------------2012-11-23重新编辑

最近突然发现gloox一直注册失败,显示错误:

log: level: 0, area: 8, This is gloox 1.0, connecting to example.com:-1...
log: level: 1, area: 32, Notice: gloox does not support SRV records on this platform. Using A records instead.
log: level: 1, area: 32, Notice: no SRV record found for example.com, using default port.
log: level: 0, area: 32, Connecting to example.com (110.173.0.130:5222)
log: level: 0, area: 32, Connected to example.com (110.173.0.130:5222)
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='36adaafb' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <stream:features xmlns:stream='http://etherx.jabber.org/streams'><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><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>
log: level: 0, area: 262144, <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
log: level: 0, area: 131072, <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
log: level: 0, area: 4, starting TLS handshake...
status: 1
issuer: example.com
peer: example.com
protocol: TLSv1/SSLv3
mac: 
cipher: ECDHE-RSA-DES-CBC3-SHA
compression: 
log: level: 0, area: 8, connection encryption active
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='36adaafb' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <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>
log: level: 1, area: 4, The server offers compression, but negotiating Compression at this stage is not recommended. See XEP-0170 for details. We'll continue anyway.
log: level: 0, area: 262144, <compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>
log: level: 0, area: 131072, <compressed xmlns='http://jabber.org/protocol/compress'/>
log: level: 0, area: 4, Stream compression initialized
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='36adaafb' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <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><auth xmlns='http://jabber.org/features/iq-auth'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
log: level: 0, area: 262144, <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>
log: level: 0, area: 131072, <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
log: level: 0, area: 4, SASL authentication successful
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='36adaafb' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <stream:features xmlns:stream='http://etherx.jabber.org/streams'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features>
log: level: 0, area: 262144, <iq id='uid:50ad858e:000041a7' type='set' from='example.com' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource/></bind></iq>
log: level: 0, area: 131072, <iq type='result' id='uid:50ad858e:000041a7' to='example.com/36adaafb'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>[email protected]/36adaafb</jid></bind></iq>
log: level: 0, area: 262144, <iq id='uid:50ad858e:10d63af1' type='set' from='[email protected]/36adaafb' xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>
log: level: 0, area: 131072, <iq type='result' id='uid:50ad858e:10d63af1' to='[email protected]/36adaafb'/>
log: level: 0, area: 262144, <presence from='[email protected]/36adaafb' xmlns='jabber:client'><priority>0</priority><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://camaya.net/gloox' ver='1LpOuB49QCQE6BcZoAF5tBoALdg='/></presence>
log: level: 0, area: 262144, <iq id='uid:50ad858e:60b7acd9' type='get' from='[email protected]/36adaafb' xmlns='jabber:client'><query xmlns='jabber:iq:register'/></iq>
RegManager --- onConnect
 log: level: 0, area: 131072, <iq type='result' id='uid:50ad858e:60b7acd9' to='[email protected]/36adaafb'><query xmlns='jabber:iq:register'><username/><password/><email/><name/><x xmlns='jabber:x:data' type='form'><title>XMPP Client Registration</title><instructions>Please provide the following information</instructions><field var='FORM_TYPE' type='hidden'><value>jabber:iq:register</value></field><field var='username' type='text-single' label='Username'><required/></field><field var='name' type='text-single' label='Full name'/><field var='email' type='text-single' label='Email'/><field var='password' type='text-private' label='Password'><required/></field></x></query></iq>
datForm received
fields: 77
instructions: 
log: level: 0, area: 262144, <iq id='uid:50ad858e:3ab50c2a' type='set' from='[email protected]/36adaafb' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>yunh222</username><password>123456</password><name/><email/></query></iq>
log: level: 0, area: 131072, <iq type='error' id='uid:50ad858e:3ab50c2a' to='[email protected]/36adaafb'><query xmlns='jabber:iq:register'><username>yunh222</username><password>123456</password><name/><email/></query><error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
result: 4
2012-11-22 09:53:19.122 云合家园[18210:592b] RegistViewController --- onRegistFail
ClientBase::streamError()---24
disconnect( ConnUserDisconnected )--!!!!!------- always crash here
log: level: 0, area: 262144, </stream:stream>
register_test: disconnected: 17

如果我不适用gloox自带的注册功能,而是直接发送注册指令(如下),就会注册成功。

<iq id='uid:50ad858e:3ab50c2a' type='set' from='[email protected]/36adaafb' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>yunh222</username><password>123456</password><name/><email/></query></iq>
纠结两天无果,昨晚躺在床上突然回忆起上面提到的openfire匿名注册,回公司检查,不知道谁将匿名注册又enable了,改之,重新注册,OK,欣喜若狂。

另附上disable登陆后的报文,以作日后对比研究使用

log: level: 0, area: 8, This is gloox 1.0, connecting to example.com:-1...
log: level: 1, area: 32, Notice: gloox does not support SRV records on this platform. Using A records instead.
log: level: 1, area: 32, Notice: no SRV record found for example.com, using default port.
log: level: 0, area: 32, Connecting to example.com (110.173.0.130:5222)
log: level: 0, area: 32, Connected to example.com (110.173.0.130:5222)
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='d922fa75' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <stream:features xmlns:stream='http://etherx.jabber.org/streams'><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</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>
log: level: 0, area: 262144, <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
log: level: 0, area: 131072, <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
log: level: 0, area: 4, starting TLS handshake...
status: 1
issuer: example.com
peer: example.com
protocol: TLSv1/SSLv3
mac: 
cipher: ECDHE-RSA-DES-CBC3-SHA
compression: 
log: level: 0, area: 8, connection encryption active
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='d922fa75' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <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>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>
log: level: 1, area: 4, The server offers compression, but negotiating Compression at this stage is not recommended. See XEP-0170 for details. We'll continue anyway.
log: level: 0, area: 262144, <compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>
log: level: 0, area: 131072, <compressed xmlns='http://jabber.org/protocol/compress'/>
log: level: 0, area: 4, Stream compression initialized
log: level: 0, area: 262144, <?xml version='1.0' ?><stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'  xml:lang='en' version='1.0'>
log: level: 0, area: 131072, <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='example.com' id='d922fa75' xml:lang='en' version='1.0'/>
log: level: 0, area: 131072, <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>CRAM-MD5</mechanism></mechanisms><auth xmlns='http://jabber.org/features/iq-auth'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
log: level: 0, area: 262144, <iq id='uid:50aedd0a:000041a7' type='get' xmlns='jabber:client'><query xmlns='jabber:iq:register'/></iq>
RegManager --- onConnect
 log: level: 0, area: 131072, <iq type='result' id='uid:50aedd0a:000041a7'><query xmlns='jabber:iq:register'><username/><password/><email/><name/><x xmlns='jabber:x:data' type='form'><title>XMPP Client Registration</title><instructions>Please provide the following information</instructions><field var='FORM_TYPE' type='hidden'><value>jabber:iq:register</value></field><field var='username' type='text-single' label='Username'><required/></field><field var='name' type='text-single' label='Full name'/><field var='email' type='text-single' label='Email'/><field var='password' type='text-private' label='Password'><required/></field></x></query></iq>
datForm received
fields: 77
instructions: 
log: level: 0, area: 262144, <iq id='uid:50aedd0a:10d63af1' type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>y11111</username><password>123456</password><name/><email/></query></iq>
log: level: 0, area: 131072, <iq type='result' id='uid:50aedd0a:10d63af1' to='example.com/d922fa75'/>
result: 0
2012-11-23 10:18:50.992 云合家园[5378:5113] RegistViewController --- onRegistSuccess
ClientBase::streamError()---24
disconnect( ConnUserDisconnected )--!!!!!------- always crash here
log: level: 0, area: 262144, </stream:stream>
register_test: disconnected: 17
2012-11-23 10:18:50.995 云合家园[5378:c07] /n RegistViewController regist successfully... /n



你可能感兴趣的:(gloox 连接 openfire 使用笔记 --openfire 配置)