Getting java.net.SocketTimeoutException: Connection timed out in android

I’ve searched all over the web and after reading lot of docs regarding connection timeout exception, the thing I understood is that, preventing SocketTimeoutException is beyond our limit. One way to effectively handle it is to define a connection timeout and later handle it by using a try-catch block. Hope this will help anyone in future who are facing … Read more

How to use java.net.URLConnection to fire and handle HTTP requests

First a disclaimer beforehand: the posted code snippets are all basic examples. You’ll need to handle trivial IOExceptions and RuntimeExceptions like NullPointerException, ArrayIndexOutOfBoundsException and consorts yourself. In case you’re developing for Android instead of Java, note also that since introduction of API level 28, cleartext HTTP requests are disabled by default. You are encouraged to use HttpsURLConnection, but if it is really … Read more

“PKIX path building failed” and “unable to find valid certification path to requested target”

Go to URL in your browser: firefox – click on HTTPS certificate chain (the lock icon right next to URL address). Click “more info” > “security” > “show certificate” > “details” > “export..”. Pickup the name and choose file type example.cer chrome – click on site icon left to address in address bar, select “Certificate” … Read more

“PKIX path building failed” and “unable to find valid certification path to requested target”

Go to URL in your browser: firefox – click on HTTPS certificate chain (the lock icon right next to URL address). Click “more info” > “security” > “show certificate” > “details” > “export..”. Pickup the name and choose file type example.cer chrome – click on site icon left to address in address bar, select “Certificate” … Read more