Android VPN connection java.net.UnknownHostException: Unable to resolve host "<url>" No address associated with hostname -
i trying connect server using vpn connection. connected pc using cisco anyconnect. when trying connect android code, find exception:
java.net.unknownhostexception: unable resolve host "<url>" no address associated hostname
here code:
try { url endpoint = new url(sauthenticateurl); httpurlconnection connection = (httpurlconnection) endpoint.openconnection(); if (connection.getresponsecode() == 200) { // success } else { // error handling code goes here } } catch (ioexception e) { e.printstacktrace(); }
the sauthenticateurl
same used pc , works on it.
note have connected android device pc internet connection, both use same network now. , pc connected vpn server.
is there specific configuration should add able access vpn android?
first of all, of cases may occur issue.
- check permission , sure have following permissions in manifest :
- android:name="android.permission.internet"
- android:name="android.permission.access_network_state"
- try disconnect network , reconnect again.
using
schemeregistery
below:keystore truststore = keystore.getinstance(keystore.getdefaulttype()); truststore.load(null, null);
sslsocketfactory sf = new mysslsocketfactory(truststore); sf.sethostnameverifier(sslsocketfactory.allow_all_hostname_verifier); httpparams params = new basichttpparams(); httpconnectionparams.setconnectiontimeout(params, 15000); httpconnectionparams.setsotimeout(params, 5000); schemeregistry registry = new schemeregistry(); registry.register(new scheme("http", plainsocketfactory.getsocketfactory(), 80)); registry.register(new scheme("https", sf, 443)); clientconnectionmanager ccm = new threadsafeclientconnmanager(params, registry); return new defaulthttpclient(ccm, params);`
Comments
Post a Comment