Authentication credentials are set here, everything works fine if the user / password is provided correctly, but it freezes if they are incorrect. This is not a server problem, I checked with Curl and Browser, invalid credentials return 401 .:
Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password.toCharArray()); } });
The code that hangs here, it hangs in this line: in = new BufferedReader (new InputStreamReader (httpURLConn.getInputStream ())); (There is no exception, it just stays on this line)
try { URL url = new URL(resourceUrl); HttpURLConnection httpURLConn = (HttpURLConnection) url.openConnection(); String rawData = ""; String currentLine = null; BufferedReader in = null; in = new BufferedReader(new InputStreamReader(httpURLConn.getInputStream())); while ((currentLine = in.readLine()) != null) { rawData = rawData.concat(currentLine); } in.close(); } catch (UnknownHostException e) { Log.i(CLASS_NAME + "::" + METHOD_NAME , "An exception occured while reading data from remote host. httpURLConn.responseCode = " + httpURLConn.getResponseCode() + " / httpURLConn.responseMessage = " + httpURLConn.getResponseMessage(), e); throw new UnknownHostException(); } catch (IOException e) { Log.i(CLASS_NAME + "::" + METHOD_NAME , "An exception occured while reading data from remote host. httpURLConn.responseCode = " + httpURLConn.getResponseCode() + " / httpURLConn.responseMessage = " + httpURLConn.getResponseMessage(), e); throw new IOException(); }
Elvin R.
source share