7

ここで認証クレデンシャルが設定されます。提供されたユーザー/パスワードが正しい場合はすべてが完全に機能しますが、正しくない場合はハングします。サーバーの問題ではありません。CurlとBrowserで確認しましたが、間違ったクレデンシャルはすぐに401を返します。:

    Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(user, password.toCharArray());
        }
    });

ハングするコードはここにあり、次の行にハングします。in = new BufferedReader(new InputStreamReader(httpURLConn.getInputStream())); (例外はありません、それはこの行にとどまります)

    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();
    }
4

1 に答える 1

0

Could it be that the server is keeping the connection alive (Keep-Alive header)?

于 2012-09-14T14:09:20.027 に答える