15 Second Delay Connecting to XMPP Server in 4.2.0

Hi,

Within the file AbstractXMPPConnection.java:

The changes from 4.1.0 to 4.2.0 to the populateHostAddresses function are, we think, are the cause of the delay in connecting to our XMPP server. Seemingly the DNS resolver is failing a number of times before finally achieving a connection. We experienced this issue when debugging over USB to a Google Pixel. We did not see this error at all using Android Studio Emulators.

If I should provide any more information, please let me know.

If I should provide any more information
Yes please. For example: Why does the DNS resolver fail a number of times?

Ah, right, yeah that’s the bit I don’t know. I couldn’t find a sensible way to get logs from that part of the code base on to the Android Device Monitor. I’m not getting any error messages at all, just a long wait. I figured it was DNS resolver, since that was the new addition in 4.1.0 to 4.2.0.

Have you tried attaching a debugger?

Hi,

So we’ve spent a while trying to further debug this. A bit more information:

  • We end up in public DNSMessage query(DNSMessage.Builder queryBuilder) method, within DNSClient, 5 times on the last count with 15 misses.

  • Within that method, the dnsServers array list contains ::1 and 10.0.0.1. ::1 always fails with an exception. MultipleIoException. Which contributes to the delay we are seeing.

  • We are then sent back through to our original DNSClient query method above, via the ResolverApi which calls that again if the dnssecClient is equal to null in the resolve method.

  • The MiniDnsResolver causes this process to happen for another couple of times, despite us finally getting a resolved aResult. The aaaaResult never resolves since our server doesn’t have IPv6.

Does this help at all? Frustratingly, we know that all we ultimately need to do is set the hostAddress within DNSUtil at line 200-ish to our address, which we already know.

Your main problem appears to be that MiniDNS has discovered a high priority DNS server at ::1 which does not respond. And since the default timeout is 5 seconds this timeout is hit on every query. Try to debug why this DNS server is discovered (and/or reported by the OS).

Thanks Flow, we are learning more everytime here. The latest is that MiniDNS looks to one of four DNSServerLookup Mechanisms, the first of which is specified as AndroidUsingExec. This spawns a process executing the “getprop” command to the device.

This in turn responds with the following relevant fields:

“net.dns2” is converted to a valid IPv6 address of ::1. As such, this mechanism returns two valid addresses of “::1” and “10.0.0.1”. The DNSClient then stops looking to further DNSServerLookupMechanisms for additional addresses.

Do you have any ideas on how we can circumnavigate this, since it seems that the device will always return two valid forms of localhost, and the aResult resolver in MiniDnsResolver will always test both as IPv4 type addresses, and consequently fail on “::1”.

Thanks for your help thus far.

AbstractXMPPConnection has a method called populateHostAddresses, which we tried to pass in Host Address from the config. However, that tried to create a HostAddress with an empty string as the fqdn, which resulted in a StringIndexOutOfBoundsException on line 48: if (fqdn.charAt(fqdn.length() - 1) == '.')

Resolved by removing reliance on MiniDNS. We have found DNSJavaResolver to be much quicker, and doesn’t produce resolution failures.

import org.jivesoftware.smack.util.DNSUtil;

import org.jivesoftware.smack.util.dns.dnsjava.DNSJavaResolver;

DNSUtil.setDNSResolver(DNSJavaResolver.getInstance());

AbstractXMPPConnection has a method called populateHostAddresses, which we tried to pass in Host Address from the config. However, that tried to create a HostAddress with an empty string as the fqdn, which resulted in a StringIndexOutOfBoundsException on line 48: if (fqdn.charAt(fqdn.length() - 1) == '.')
That is fixed in 4.2.0-rc2-SNAPSHOT. The MiniDNS version got also bumped in 4.2.0-rc1, so the overall behavior should have improved.

Resolved by removing reliance on MiniDNS. We have found DNSJavaResolver to be much quicker, and doesn’t produce resolution failures.

I don’t recommend using dnsjava on Android, for various reasons. For example dnsjava’s mechanism to detect the system’s DNS server are not ideal on Android. And that is me, who did - Improve the name server detection code for Android. · dnsjava/dnsjava@563aae1 · GitHub , saying it.

Can you say when rc2 will be available on maven?

Can you say when rc2 will be available on maven?
The snapshots are already available in Maven Centrals snapshot repository.

We’re also very worried about long connection time (sometimes).

I’m not an expert in DNS client, but problem seems to be there (there was nothing similar on previous versions of MiniDnsClient).

I adjusted logging to catch Smack and MiniDns log on Android, hope it can help:

2017-01-14_16-12-28 <<< android network down >>>

2017-01-14_16-12-28 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ PacketWriter shutdown()

2017-01-14_16-12-28 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ Reporting shutdownDone success in writer thread

2017-01-14_16-12-28 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ PacketWriter has been shut down

2017-01-14_16-12-28 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ PacketReader shutdown()

2017-01-14_16-12-28 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ PacketReader has been shut down

2017-01-14_16-12-28 W/org.jivesoftware.smack.AbstractXMPPConnection: Connection XMPPTCPConnection[] (0) closed with error

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ javax.net.ssl.SSLException: Read error: ssl=0x68b588f8: I/O error during system call, Connection timed out

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:705)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ java.io.InputStreamReader.read(InputStreamReader.java:233)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ java.io.BufferedReader.read(BufferedReader.java:325)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.kxml2.io.KXmlParser.next(KXmlParser.java:349)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.kxml2.io.KXmlParser.next(KXmlParser.java:313)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1227)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:980)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:995)

2017-01-14_16-12-28 E/org.jivesoftware.smack.AbstractXMPPConnection﹕ java.lang.Thread.run(Thread.java:818)

2017-01-14_16-12-28 W/org.jivesoftware.smackx.ping.PingManager: Exception while pinging server of XMPPTCPConnection[] (0)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.lang.InterruptedException

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInt erruptAfterWait(AbstractQueuedSynchronizer.java:1988)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNano s(AbstractQueuedSynchronizer.java:2063)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.ArrayBlockingQueue.poll(ArrayBlockingQueue.java:372)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smack.StanzaCollector.nextResult(StanzaCollector.java:185)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:2 47)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smackx.ping.PingManager.ping(PingManager.java:170)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smackx.ping.PingManager.pingMyServer(PingManager.java:253)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smackx.ping.PingManager.pingMyServer(PingManager.java:234)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smackx.ping.PingManager.pingServerIfNecessary(PingManager.java :377)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ org.jivesoftware.smackx.ping.PingManager$4.run(PingManager.java:407)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.FutureTask.run(FutureTask.java:237)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:154)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu ledThreadPoolExecutor.java:269)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)

2017-01-14_16-12-28 E/org.jivesoftware.smackx.ping.PingManager﹕ java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)

2017-01-14_16-12-28

2017-01-14_16-12-28 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-28 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-12-28 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-30 <<< android mobile network connected (HSPA) >>>

2017-01-14_16-12-31 <<< android wifi connected >>>

2017-01-14_16-12-33 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-12-33 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-33 D/de.measite.minidns.AbstractDNSClient﹕ Response from {0} on {1} for {2}:

{3}

2017-01-14_16-12-33 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-43 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-12-43 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-43 D/de.measite.minidns.AbstractDNSClient﹕ Response from {0} on {1} for {2}:

{3}

2017-01-14_16-12-43 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-53 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-12-53 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-12-53 D/de.measite.minidns.AbstractDNSClient﹕ Response from {0} on {1} for {2}:

{3}

2017-01-14_16-12-53 D/org.jivesoftware.smack.util.DNSUtil﹕ Resolved SRV RR for _xmpp-client.: :5222 prio:10:w:5

2017-01-14_16-12-54 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-13-04 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-13-04 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-13-04 D/de.measite.minidns.AbstractDNSClient﹕ Response from {0} on {1} for {2}:

{3}

2017-01-14_16-13-04 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-13-14 D/de.measite.minidns.AbstractDNSClient﹕ IOException {0} on {1} while resolving {2}: {3}

2017-01-14_16-13-14 D/de.measite.minidns.AbstractDNSClient﹕ Asking {0} on {1} for {2} with:

{3}

2017-01-14_16-13-14 D/de.measite.minidns.AbstractDNSClient﹕ Response from {0} on {1} for {2}:

{3}

2017-01-14_16-13-14 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ Trying to establish TCP connection to / at port 5222

2017-01-14_16-13-14 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ Established TCP connection to / at port 5222

Thanks Grigory. Unfortunately your JUL handler does not format the log messages. That makes it hard to tell which DNS server does cause the exception. We also don’t see the exception message which would be very helpful. In order to format the log messages, try something like JUL: Format the log message · ProjectMAXS/maxs@d48b072 · GitHub , i.e. use Formatter.formatMessage(LogRecord).

When it’s formated, we should not only see the used DNS servers but also the message of the IOException. It would be great if you could show us a formatted log when you have one.

I do believe that the culprit is in your and OP’s case a lame or faulty DNS server, like “::1” without having a DNS resolver listening on the IPv6 localhost.

Thanks for help, Flow!

I use log formatting now, here is a sample. But in this particular case it seems that android hanged network for two minutes (Android 6)… But the application is in battery white list. I will add logs with other cases as soon as I get them.

2017-01-16_14-32-39 <<< Android LTE connected >>>

2017-01-16_14-32-40 <<< Starting connection… >>>

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.118 on 53 for _xmpp-client._tcp.redsolution.com. IN SRV with:

DNSMessage(24664 QUERY NO_ERROR query[qr=0] rd)

[Q: _xmpp-client._tcp.redsolution.com. IN SRV]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Response from /10.10.30.118 on 53 for _xmpp-client._tcp.redsolution.com. IN SRV:

DNSMessage(24664 QUERY NO_ERROR resp[qr=1] rd ra)

[Q: _xmpp-client._tcp.redsolution.com. IN SRV]

[A: _xmpp-client._tcp.redsolution.com. 24466 IN SRV 10 5 5222 raven.redsolution.ru.]

[N: redsolution.com. 24466 IN NS ns5.linode.com.]

[N: redsolution.com. 24466 IN NS ns4.linode.com.]

[N: redsolution.com. 24466 IN NS ns1.linode.com.]

[N: redsolution.com. 24466 IN NS ns2.linode.com.]

[N: redsolution.com. 24466 IN NS ns3.linode.com.]

[X: raven.redsolution.ru. 25195 IN A 188.226.175.57]

[X: ns1.linode.com. 9997 IN A 162.159.27.72]

[X: ns1.linode.com. 57170 IN AAAA 2400:cb00:2049:1:0:0:a29f:1a63]

[X: ns2.linode.com. 106294 IN A 162.159.24.39]

[X: ns2.linode.com. 106294 IN AAAA 2400:cb00:2049:1:0:0:a29f:1827]

[X: ns3.linode.com. 106294 IN A 162.159.25.129]

[X: ns3.linode.com. 106294 IN AAAA 2400:cb00:2049:1:0:0:a29f:1981]

[X: ns4.linode.com. 137673 IN A 162.159.26.99]

[X: ns4.linode.com. 137673 IN AAAA 2400:cb00:2049:1:0:0:a29f:1b48]

[X: ns5.linode.com. 144650 IN A 162.159.24.25]

[X: ns5.linode.com. 144650 IN AAAA 2400:cb00:2049:1:0:0:a29f:1819]

[X: EDNS: version: 0, flags:; udp: 4096]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.118 on 53 for raven.redsolution.ru. IN A with:

DNSMessage(48154 QUERY NO_ERROR query[qr=0] rd)

[Q: raven.redsolution.ru. IN A]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Response from /10.10.30.118 on 53 for raven.redsolution.ru. IN A:

DNSMessage(48154 QUERY NO_ERROR resp[qr=1] rd ra)

[Q: raven.redsolution.ru. IN A]

[A: raven.redsolution.ru. 25195 IN A 188.226.175.57]

[N: redsolution.ru. 40869 IN NS ns2.linode.com.]

[N: redsolution.ru. 40869 IN NS ns3.linode.com.]

[N: redsolution.ru. 40869 IN NS ns5.linode.com.]

[N: redsolution.ru. 40869 IN NS ns4.linode.com.]

[N: redsolution.ru. 40869 IN NS ns1.linode.com.]

[X: ns1.linode.com. 9997 IN A 162.159.27.72]

[X: ns1.linode.com. 57170 IN AAAA 2400:cb00:2049:1:0:0:a29f:1a63]

[X: ns2.linode.com. 106294 IN A 162.159.24.39]

[X: ns2.linode.com. 106294 IN AAAA 2400:cb00:2049:1:0:0:a29f:1827]

[X: ns3.linode.com. 106294 IN A 162.159.25.129]

[X: ns3.linode.com. 106294 IN AAAA 2400:cb00:2049:1:0:0:a29f:1981]

[X: ns4.linode.com. 137673 IN A 162.159.26.99]

[X: ns4.linode.com. 137673 IN AAAA 2400:cb00:2049:1:0:0:a29f:1b48]

[X: ns5.linode.com. 144650 IN A 162.159.24.25]

[X: ns5.linode.com. 144650 IN AAAA 2400:cb00:2049:1:0:0:a29f:1819]

[X: EDNS: version: 0, flags:; udp: 4096]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.118 on 53 for raven.redsolution.ru. IN AAAA with:

DNSMessage(5738 QUERY NO_ERROR query[qr=0] rd)

[Q: raven.redsolution.ru. IN AAAA]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Response from /10.10.30.118 on 53 for raven.redsolution.ru. IN AAAA:

DNSMessage(5738 QUERY NO_ERROR resp[qr=1] rd ra)

[Q: raven.redsolution.ru. IN AAAA]

[N: redsolution.ru. 6000 IN SOA ns1.linode.com. webmaster.redsolution.ru. 2017011212 14400 14400 1209600 86400]

[X: EDNS: version: 0, flags:; udp: 4096]

2017-01-16_14-32-40 D/org.jivesoftware.smack.util.DNSUtil﹕ Resolved SRV RR for _xmpp-client._tcp.redsolution.com: raven.redsolution.ru:5222 prio:10:w:5

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.118 on 53 for redsolution.com. IN A with:

DNSMessage(24218 QUERY NO_ERROR query[qr=0] rd)

[Q: redsolution.com. IN A]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Response from /10.10.30.118 on 53 for redsolution.com. IN A:

DNSMessage(24218 QUERY NO_ERROR resp[qr=1] rd ra)

[Q: redsolution.com. IN A]

[A: redsolution.com. 25804 IN A 178.79.128.253]

[N: redsolution.com. 24465 IN NS ns4.linode.com.]

[N: redsolution.com. 24465 IN NS ns2.linode.com.]

[N: redsolution.com. 24465 IN NS ns5.linode.com.]

[N: redsolution.com. 24465 IN NS ns1.linode.com.]

[N: redsolution.com. 24465 IN NS ns3.linode.com.]

[X: ns1.linode.com. 9996 IN A 162.159.27.72]

[X: ns1.linode.com. 57169 IN AAAA 2400:cb00:2049:1:0:0:a29f:1a63]

[X: ns2.linode.com. 106293 IN A 162.159.24.39]

[X: ns2.linode.com. 106293 IN AAAA 2400:cb00:2049:1:0:0:a29f:1827]

[X: ns3.linode.com. 106293 IN A 162.159.25.129]

[X: ns3.linode.com. 106293 IN AAAA 2400:cb00:2049:1:0:0:a29f:1981]

[X: ns4.linode.com. 137672 IN A 162.159.26.99]

[X: ns4.linode.com. 137672 IN AAAA 2400:cb00:2049:1:0:0:a29f:1b48]

[X: ns5.linode.com. 144649 IN A 162.159.24.25]

[X: ns5.linode.com. 144649 IN AAAA 2400:cb00:2049:1:0:0:a29f:1819]

[X: EDNS: version: 0, flags:; udp: 4096]

2017-01-16_14-32-40 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.118 on 53 for redsolution.com. IN AAAA with:

DNSMessage(12865 QUERY NO_ERROR query[qr=0] rd)

[Q: redsolution.com. IN AAAA]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-32-44 <<< Android WiFI connected >>>

2017-01-16_14-34-52 <<< Android Screen is on >>>

2017-01-16_14-34-56 D/de.measite.minidns.AbstractDNSClient﹕ IOException /10.10.30.118 on 53 while resolving redsolution.com. IN AAAA: de.measite.minidns.util.MultipleIoException: null, failed to connect to /10.10.30.118 (port 53) after 5000ms: isConnected failed: ENETUNREACH (Network is unreachable)

2017-01-16_14-34-56 D/de.measite.minidns.AbstractDNSClient﹕ Asking /10.10.30.122 on 53 for redsolution.com. IN AAAA with:

DNSMessage(12865 QUERY NO_ERROR query[qr=0] rd)

[Q: redsolution.com. IN AAAA]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-35-01 D/de.measite.minidns.AbstractDNSClient﹕ IOException /10.10.30.122 on 53 while resolving redsolution.com. IN AAAA: de.measite.minidns.util.MultipleIoException: null, failed to connect to /10.10.30.122 (port 53) after 5000ms: isConnected failed: ENETUNREACH (Network is unreachable)

2017-01-16_14-35-01 D/de.measite.minidns.AbstractDNSClient﹕ Asking /8.8.8.8 on 53 for redsolution.com. IN AAAA with:

DNSMessage(12865 QUERY NO_ERROR query[qr=0] rd)

[Q: redsolution.com. IN AAAA]

[X: EDNS: version: 0, flags:; udp: 1024]

2017-01-16_14-35-02 D/de.measite.minidns.AbstractDNSClient﹕ Response from /8.8.8.8 on 53 for redsolution.com. IN AAAA:

DNSMessage(12865 QUERY NO_ERROR resp[qr=1] rd ra)

[Q: redsolution.com. IN AAAA]

[N: redsolution.com. 1799 IN SOA ns1.linode.com. webmaster.redsolution.ru. 2016122205 14400 14400 1209600 86400]

[X: EDNS: version: 0, flags:; udp: 512]

2017-01-16_14-35-02 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ Trying to establish TCP connection to /188.226.175.57 at port 5222

2017-01-16_14-35-02 D/org.jivesoftware.smack.tcp.XMPPTCPConnection﹕ Established TCP connection to /188.226.175.57 at port 5222

And here are better examples. Both using Android 7.1, LTE, Screen is on. Connection to XMPP server creep.im took long time:

Smack 4.2.0-rc2 long time reconnection on Android · GitHub

Smack 4.2.0-rc2 long time reconnection on Android · GitHub

What we see is that MiniDNS tries to use the IPv6 localhost for resolution, which does not answer after the default 5 second timeout, and then another IP is used. This is similar to @Nick.

The question now is: Where does that faulty entry come from? The most promising candidates are MiniDNS’s AndroidUsingExec and AndroidUsingReflection DNSServerLookupMechanims. Could you set a break point in their getDnsServerAddresses() and see if the returned string array contains “::1”?

I found out that AndroidUsingExec returns [::1, 83.149.33.203, 83.149.33.196].

It get ::1 from “[net.r_rmnet_data0.dns1]: []” and “[net.r_rmnet_data0.dns2]: []”

So you are saying the ‘value’ in AndroidUsingExec is the empty String? And that InetAddress.getByName(value); returns the localhost if it’s called with the empty string? In that case we can fix AndroidUsingExec by filtering the empty string (in value).

Yes, I also think that filtering empty string can help.

I’ve uploaded Filter out empty values in AndroidUsingExec · Flowdalic/minidns@f46491a · GitHub to my github repo. Can you copy the improved version of AndroidUsingExec into your codebase, then install that version using DNSClient.addDnsServerLookupMechanism(), removing the old one using removeDNSServerLookupMechanism() and report back if it fixes the issue?