powered by Jive Software

Smack only using Google DNS for SRV (Android)

When you configure Smack to auto-resolve the server from the XMPP domain (using XMPPTCPConnectionConfiguration.setXmppDomain() only), it will never connect to private domains / will fail to work on networks that make use of DNS firewalling.

This is due to Smack using MiniDns, and MiniDns having hard-coded Google servers.

Even if SRV resolution fails because 8.8.8.8 can’t be contacted, there is no fallback to A/AAAA-lookup using local servers afterwards.

I am not sure if you are reporting one issue here or two.

  1. Smack (and MiniDNS) should always try to resolve SRV and A/AAAA RRs, irregardless of a query failing for whatever reason. If this is not the case with current Smack, then this should be fixed.

  2. The hardcoded DNS servers are (/should) be used as last resort. So if 8.8.8.8 can’t be contacted, then MiniDNS was before unable to determine and contact the “system” resolver. This would be an indication that MiniDNS was not able to determine the “system” resolver IPs. Note that on newer Android versions you want to use [minidns-android21]
    (https://github.com/MiniDNS/minidns/tree/master/minidns-android21), to reliable determine the system, or even, per link, resolver.

Not directly related, but this MiniDNS issue has some background information about the hardcoded DNS server used:

Thanks for the background links. I’ve seen minidns-android21 before, but the project lacks any information about how/when to deploy it. Is “android 21” the targetSdkVersion where this workaround is required, or the minSdkVersion supported?

It looks like smack-android is pulling in minidns-android21, but the comment claims it is “optional”, which I’m not sure is correct from the gradle file. From following the comments in various places, it looks like my code isn’t initializing the AndroidUsingLinkProperties class, which is normally done by smack-android.

Looks like I’ve gone a looong way without this, but adding it fixed the issue for me:

AndroidSmackInitializer.initialize(this);

Thanks very much!