twk
twk

Reputation: 17320

DNS problems on Android

I had gotten reports from a few users that they couldn't login to our app (which makes HTTP calls to our site) or visit our website in their browser, so I added some code to our latest build to check what IP our host name is resolving to. I've gotten reports from several different users now that they get 127.0.0.1 for our hostname when the app starts, which obviously isn't going to work.

They claim they aren't running any proxy software, and this happens on both 2.1 and 2.2. This also happens on both wifi & 3g, which makes me suspect it is some piece of software on their phone that is interfering with DNS resolution somehow. Does anyone know of any popular software that might do that? Or does anyone have any ideas about how to identify which software might be doing it?

Thanks,

Upvotes: 3

Views: 3045

Answers (3)

diyism
diyism

Reputation: 12935

dnsjava/org.xbill.DNS is too big for android app, Scott Means's DNSQuery is promiseful:

http://smeans.com/programming/dns-queries-in-java/

Upvotes: 0

user1361305
user1361305

Reputation: 11

import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;

public class DNSLookUpActivity extends Activity {
    private String url = "https://spectracore.americanlogistics.com/rdac/AdmissionController/CheckMddAdmission";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        funDNS(url);

    }

    private static void funDNS(String url) {

        try {
            Lookup lookup = new Lookup(url, Type.ANY);
            Record[] records = lookup.run();

            if (lookup.getResult() == Lookup.SUCCESSFUL) {
                String responseMessage = null;
                String listingType = null;
                for (int i = 0; i < records.length; i++) {
                    if (records[i] instanceof TXTRecord) {
                        TXTRecord txt = (TXTRecord) records[i];
                        for (Iterator j = txt.getStrings().iterator(); j
                                .hasNext();) {
                            responseMessage += (String) j.next();
                        }
                        Log.e("TXRecord ", "" + responseMessage);
                    } else if (records[i] instanceof ARecord) {
                        listingType = ((ARecord) records[i]).getAddress()
                                .getHostAddress();
                        Log.e("ARecord address : ", "" + listingType);
                    }
                }
            }
        } catch (TextParseException e) {
            e.printStackTrace();
        }

    }
}
Need android ask version 2.3.3 or above

Upvotes: 1

benc
benc

Reputation: 2051

Get their DNS config, and try their DNS servers directly with dig or nslookup. This is not perfect, but it has a good chance of showing you the problem.

Upvotes: 0

Related Questions