Smack 4.0.5 - javax.naming.NameNotFoundException: DNS name not found

I am newbie using smack 4.0.5. Openfire is configured and running, I have a test with Kopete client (in kubuntu) and works fine.

In my java program using smack 4.0.5 version

"XMPPConnection con = new XMPPTCPConnection (“localhost”);

con.connect();"

exception occurs

org.jivesoftware.smack.SmackException: javax.naming.NameNotFoundException: DNS name not found [response code 3]; remaining ‘_xmpp-client._tcp.localhost’ name

Does anyone know if the error is related to the https://igniterealtime.org/issues/browse/SMACK-616?

use ip instead of localhost

such as:

XMPPConnection con = new XMPPTCPConnection (“192.168.1.1”);

Yes it’s caused by SMACK-616

1 Like

Using the ip didnt work.

XMPPConnection con = new XMPPTCPConnection (“127.0.0.1”);

org.jivesoftware.smack.SmackException: javax.naming.NameNotFoundException: DNS name not found [response code 3]; remaining ‘_xmpp-client._tcp.127.0.0.1’

Using the code below, it worked.

ConnectionConfiguration config = new ConnectionConfiguration(“localhost”, 5222);
config.setSecurityMode(SecurityMode.disabled);
XMPPConnection con = new XMPPTCPConnection(config);

Using jar files SNAPSHOT 4.0.6 this exception occurs.

I’m using openfire 3.9.3, it’s possible disable the SSL ? Or, How to solve this error ?

XMPPConnection con = new XMPPTCPConnection (“localhost”);

Nov 22, 2014 10:48:16 AM org.jivesoftware.smack.util.DNSUtil resolveDomain

WARNING: Exception while resovling SRV records for localhost. Consider adding ‘_xmpp-(server|client)._tcp’ DNS SRV Records

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Nov 22, 2014 10:48:18 AM org.jivesoftware.smack.tcp.PacketWriter writePackets

WARNING: Exception writing closing stream element

java.net.SocketException: Socket closed

at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121)

at java.net.SocketOutputStream.write(SocketOutputStream.java:159)

at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)

at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)

at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)

at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)

at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)

at java.io.BufferedWriter.flush(BufferedWriter.java:254)

at org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)

at org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)

at org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

Set SecurityMode to disabled or use a SSLContext that validates the server cert (e.g. by using Flowdalic/java-pinning · GitHub )