gpt4 book ai didi

android - smack 4.2.0 错误 : IN AAAA yielded an error response NX_DOMAIN

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:19:14 26 4
gpt4 key购买 nike

我启动 openFire 并用 spark 测试它一切正常但是当我尝试在 android studio 中连接 smack 4.2.0 时我得到了这个错误:

Ljavax/命名/目录/InitialDirContext;

我的依赖是这样的:

compile "org.igniterealtime.smack:smack-java7:4.2.0" compile "org.igniterealtime.smack:smack-tcp:4.2.0" compile "org.igniterealtime.smack:smack-im:4.2.0" compile "org.igniterealtime.smack:smack-extensions:4.2.0" compile "org.igniterealtime.smack:smack-android-extensions:4.2.0" compile "org.igniterealtime.smack:smack-bosh:4.2.0"

删除时:“编译 org.igniterealtime.smack:smack-java7:4.2.0”从依赖项中添加:编译“org.igniterealtime.smack:smack-android:4.2.0”我的依赖关系变成这样:

compile 'com.android.support:appcompat-v7:24.0.0' compile "org.igniterealtime.smack:smack-android:4.2.0" compile "org.igniterealtime.smack:smack-tcp:4.2.0" compile "org.igniterealtime.smack:smack-im:4.2.0" compile "org.igniterealtime.smack:smack-extensions:4.2.0" compile "org.igniterealtime.smack:smack-android-extensions:4.2.0" compile "org.igniterealtime.smack:smack-bosh:4.2.0"

我得到了这个错误:

org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: '192.168.209.2:5222' failed because: de.measite.minidns.hla.ResolutionUnsuccessfulException: Asking for 192.168.209.2. IN A yielded an error response NX_DOMAIN, '192.168.209.2:5222' failed because: de.measite.minidns.hla.ResolutionUnsuccessfulException: Asking for 192.168.209.2. IN AAAA yielded an error response NX_DOMAIN

当我尝试 conn.connect() 时出错的代码部分是这样的:

XMPPTCPConnectionConfiguration config = null;  
try {
config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("admin", "thepass")
.setXmppDomain("192.168.1.3")
.setHost("192.168.209.2")
.setPort(5222)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.build();
} catch (Exception e) {
e.printStackTrace();
}
AbstractXMPPConnection conn1 = new XMPPTCPConnection(config);
conn1.setReplyTimeout(60000);
conn1.setPacketReplyTimeout(60000);
conn1.connect();

最佳答案

您遇到的错误是由于您的 XMPP 服务器寻址不完整造成的。

想象一下这个场景:

my ejabberd server is running on this address: 192.168.209.2 #ejabberd server

有一个名为“localhost”的xmpp域有两个JID,

"davood@localhost" and "sadegh@localhost"

在 smack 中,我想对我的用户进行身份验证,说“davood@localhost”。然后我这样做:

            InetAddress addr = InetAddress.getByName("192.168.209.2");
HostnameVerifier verifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return false;
}
};
DomainBareJid serviceName = JidCreate.domainBareFrom("localhost");
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setHost(server) # it will be resolved by setHostAddress method
.setUsernameAndPassword("davood","mypass")
.setPort(5222)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setXmppDomain(serviceName)
.setHostnameVerifier(verifier)
.setHostAddress(addr)
.setDebuggerEnabled(true)
.build();
AbstractXMPPConnection conn1 = new XMPPTCPConnection(config);

conn1.connect();

if(conn1.isConnected()){
Log.d("XMPP","Connected");
}
conn1.login();

if(conn1.isAuthenticated()){
Log.d("XMPP","Authenticated");
EntityBareJid jid = JidCreate.entityBareFrom("sadegh@localhost");
org.jivesoftware.smack.chat2.Chat chat = ChatManager.getInstanceFor(conn1).chatWith(jid);
chat.send("Eureka, I am connected!");


}

关于android - smack 4.2.0 错误 : IN AAAA yielded an error response NX_DOMAIN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43143359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com