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?
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?