• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Host-name resolution fails when connected to mobile network

Nilesh10

Lurker
Mar 22, 2019
1
0
Hello,

We are trying to connect to local device WiFi Access Pont with no internet connection to provision it for IoT.
Following are our observations.
1) Call device API by hostname e.g. (https://vrd-1234/api/ping):-
a. When mobile data is off and connected to device AP:-
We were able to establish a connection properly and received a success response.

b. When mobile data is On and connected to device AP:-
Received UnkownHostException because OS is not able to resolve IP even though the local device has its own DNS.

2) Call device API by its IP e.g (https://192.168.1.81/api/ping)
a. When mobile data is Off and connected to device AP:-
It throws SSLPeerUnverifiedException because of certificate checks are failing. Here suggested solution is to add IPs in cerrtificate. But because of costing issued we cant opt for this option.

b. When mobile data in On and connected to device AP:-
It throws TimeoutException because OS is still trying to resolve IP globally always because mobile data is on. Android always seems to override its DNS entries using Google's servers.

To summarize, the HostName resolution fails when mobile data is on.
So How to force a local hostname resolution programmatically even if mobile data is on and Android is connected to device AP?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones