0

我正在HTTP/GET通过 SSL 连接的简单请求将一组 CSV 行下载到我的 android 设备。在我们切换到新服务器(Debian 6 -> Debian 7)之前,这就像一个魅力,这可能是服务器证书的问题,但我不这么认为,因为下载开始并在此异常之前解析了大约 700 篇文章被抛出.readLine()

(请注意,该下载已在 Android ICS (4.*) 上进行了测试,并且没有任何问题,它似乎只影响 Android <= 2.3。)

Read error: ssl=0x35e700: Failure in SSL library, usually a protocol error
javax.net.ssl.SSLProtocolException: Read error: ssl=0x35e700: Failure in SSL library, usually a protocol error
    at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
    at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:788)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)
    at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:161)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:159)
    at java.io.InputStreamReader.read(InputStreamReader.java:255)
    at java.io.BufferedReader.fillBuf(BufferedReader.java:128)
    at java.io.BufferedReader.readLine(BufferedReader.java:357)
    at xx.xxxxx.services.ArticlesSync.doInBackground(ArticlesSync.java:155)
    at xx.xxxxx.services.ArticlesSync.doInBackground(ArticlesSync.java:26)
    at android.os.AsyncTask$2.call(AsyncTask.java:185)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
    at java.lang.Thread.run(Thread.java:1019)

|

InputStream inputStream = response.getContent();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

String currentLine = null;
SQLArticleManager articles = SQLArticleManager.createArticles();
while ((currentLine = bufferedReader.readLine()) != null)
{
    if (!progressDialog.isShowing())
    {
        return ERROR_ABORTED;
    }

    String[] data = currentLine.split("`");

    if (data.length == 4)
    {
        articles.addArticle(data[0], data[1], data[2], Float.parseFloat(data[3]));
    }

    rowsRead++;
    publishProgress(createProgress((int) (rowsRead * 100 / rows), ""));
}

我在这里做错了吗?可能是由于某处超时吗?

4

1 回答 1

1

很抱歉成为坏消息的承担者,但这是一个影响版本 2.2-2.3.3(API 级别 9 和 10)的已知 Android 错误。有关更多详细信息,请参阅此错误此错误

进一步的讨论记录这可能是关于根 CA 的问题,但那里的第二个链接与此数据冲突,所以我不认为是这种情况。

我认为有效的方法(尽管我没有模拟一个快速样本来验证)是明确使用 4k 缓冲区与getInputStream(),即

private static final int BUFFER_SIZE = 4096;

希望有帮助。

于 2013-10-06T00:35:00.647 回答