首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Openfire Smack连接问题

Openfire Smack连接问题
EN

Stack Overflow用户
提问于 2015-06-08 15:34:18
回答 1查看 2.5K关注 0票数 3

这是我第一次使用Openfire & smack。详情如下:

  • 版本: Openfire 3.10.0
  • 服务器目录: /opt/openfire Server
  • 名称: ubuntu

环境

  • Java版本: 1.7.0_79甲骨文公司-- OpenJDK 64位服务器VM
  • Appserver: jetty/9.2.z-快照
  • 主机名称: ubuntu

我正在使用最新版本的Smack 4.1

这是密码:

代码语言:javascript
复制
    public XMPPManager() 
{   
    XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
            .setServiceName("ubuntu")
            //.setHost("127.0.0.1")
            .setPort(5222)
            .setSecurityMode(SecurityMode.disabled)
            .setDebuggerEnabled(true).build();

    AbstractXMPPConnection mConnection = new XMPPTCPConnection(config);

    try 
    {
        System.out.println("connecting");
        mConnection.setPacketReplyTimeout(10000);
        mConnection.connect();
        System.out.println("connected");
        mConnection.login("tuser1", "test1");

    } 
    catch (SmackException | IOException | XMPPException e) 
    {
        e.printStackTrace();
    }

}

现在,当我运行这段代码时,我会得到以下错误:

代码语言:javascript
复制
    Java project working, Hello World !!
connecting
Jun 08, 2015 8:16:49 AM org.jivesoftware.smack.util.DNSUtil resolveDomain
WARNING: Exception while resovling SRV records for ubuntu. Consider adding '_xmpp-(server|client)._tcp' DNS SRV Records
javax.naming.NameNotFoundException: DNS name not found [response code 3]; remaining name '_xmpp-client._tcp.ubuntu'
    at com.sun.jndi.dns.DnsClient.checkResponseCode(DnsClient.java:654)
    at com.sun.jndi.dns.DnsClient.isMatchResponse(DnsClient.java:572)
    at com.sun.jndi.dns.DnsClient.doUdpQuery(DnsClient.java:421)
    at com.sun.jndi.dns.DnsClient.query(DnsClient.java:210)
    at com.sun.jndi.dns.Resolver.query(Resolver.java:81)
    at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:430)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:231)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:139)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:127)
    at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
    at org.jivesoftware.smack.util.dns.javax.JavaxResolver.lookupSRVRecords(JavaxResolver.java:78)
    at org.jivesoftware.smack.util.DNSUtil.resolveDomain(DNSUtil.java:171)
    at org.jivesoftware.smack.util.DNSUtil.resolveXMPPDomain(DNSUtil.java:120)
    at org.jivesoftware.smack.AbstractXMPPConnection.populateHostAddresses(AbstractXMPPConnection.java:569)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:552)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:830)
    at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:360)
    at XMPPManager.<init>(XMPPManager.java:29)
    at Main.main(Main.java:12)

08:16:49 AM SENT (0): <stream:stream xmlns='jabber:client' to='ubuntu' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
08:16:49 AM RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="ubuntu" id="3197fe6e" xml:lang="en" version="1.0"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls><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>
connected
08:16:50 AM SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'>=</auth>
08:16:50 AM RECV (0): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09InVidW50dSIsbm9uY2U9InFva3NTWFkveDZSQTh1bmJpb3FSQjZKY2NhSnhsd3JsNXBWZEVzakUiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
08:16:50 AM SENT (0): <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>Y2hhcnNldD11dGYtOCx1c2VybmFtZT0idHVzZXIxIixyZWFsbT0idWJ1bnR1Iixub25jZT0icW9rc1NYWS94NlJBOHVuYmlvcVJCNkpjY2FKeGx3cmw1cFZkRXNqRSIsbmM9MDAwMDAwMDEsY25vbmNlPSJoanlFaTl4N1BZTCtZb1VCQmZXRDJWNjF6M2doSzlBOW43Tlh6RDgyIixkaWdlc3QtdXJpPSJ4bXBwL3VidW50dSIsbWF4YnVmPTY1NTM2LHJlc3BvbnNlPTliMGM5YzBiOGNmYjVlOTYzNmI1ZDUyOWFlOTgwNThkLHFvcD1hdXRo</response>
08:16:50 AM RECV (0): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD02OGY5MTNhNDNmOWYyNzIxMTViM2I5YTc4ZDBhM2JlOA==</success>
08:16:50 AM SENT (0): <stream:stream xmlns='jabber:client' to='ubuntu' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='3197fe6e' xml:lang='en'>
08:16:50 AM RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="ubuntu" id="3197fe6e" xml:lang="en" version="1.0"><stream:features><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"><optional/></session></stream:features>
08:16:50 AM SENT (0): <iq id='hqopf-3' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Smack</resource></bind></iq>
08:16:50 AM RECV (0): <iq type="result" id="hqopf-3" to="ubuntu/3197fe6e"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>tuser1@ubuntu/Smack</jid></bind></iq>
08:16:50 AM User logged (0): tuser1@ubuntu:5222/Smack
08:16:50 AM SENT (0): <iq id='hqopf-5' type='get'><query xmlns='jabber:iq:roster'></query></iq>
08:16:50 AM RECV (0): <iq type="result" id="hqopf-5" to="tuser1@ubuntu/Smack"><query xmlns="jabber:iq:roster"/></iq>
08:16:50 AM XMPPConnection authenticated (0)
08:16:50 AM SENT (0): <presence id='hqopf-7'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>
08:16:50 AM RECV (0): <iq type="get" id="360-5" to="tuser1@ubuntu/Smack" from="ubuntu"><query xmlns="http://jabber.org/protocol/disco#info"/></iq>
08:16:50 AM SENT (0): <iq to='ubuntu' id='360-5' type='result'><query xmlns='http://jabber.org/protocol/disco#info'><identity category='client' name='Smack' type='pc'/><feature var='http://jabber.org/protocol/commands'/><feature var='http://jabber.org/protocol/xhtml-im'/><feature var='jabber:iq:privacy'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='vcard-temp'/><feature var='urn:xmpp:time'/><feature var='jabber:iq:last'/><feature var='urn:xmpp:ping'/><feature var='jabber:x:data'/><feature var='http://jabber.org/protocol/bytestreams'/><feature var='http://jabber.org/protocol/muc'/><feature var='http://jabber.org/protocol/xdata-validate'/><feature var='jabber:iq:version'/><feature var='http://jabber.org/protocol/xdata-layout'/><feature var='urn:xmpp:receipts'/><feature var='http://jabber.org/protocol/caps'/><feature var='http://jabber.org/protocol/disco#info'/></query></iq>
08:16:50 AM RECV (0): <presence id="hqopf-7" from="tuser1@ubuntu/Smack" to="tuser1@ubuntu/Smack"><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.igniterealtime.org/projects/smack" ver="NfJ3flI83zSdUDzCEICtbypursw="/></presence><presence from="testuser2@ubuntu" to="tuser1@ubuntu" type="subscribe"/>

到底出了什么问题。我看不到openfire管理控制台上的任何会话。服务器安装在Ubuntu12.04.3 (localhost)上

EN

回答 1

Stack Overflow用户

发布于 2015-10-19 09:48:25

您的连接设置是错误的,在这里使用如下:

代码语言:javascript
复制
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
        .setServiceName("127.0.0.1")
        .setHost("127.0.0.1")
        .setPort(5222)
        .setSecurityMode(SecurityMode.disabled)
        .setDebuggerEnabled(true).build();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30713397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档