Android的HttpURLConnection的抛EOFException类 [英] Android HttpURLConnection throwing EOFException

查看:275
本文介绍了Android的HttpURLConnection的抛EOFException类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是在最简单的方式的问题。

Here's the question in simplest way.

我创建通过代理服务器使用的HttpURLConnection对象HTTPS连接到我的服务器。

I create a HTTPS connection to my server through proxy using HttpUrlConnection Object.

我的代理服务器将关闭连接,但我的code仍然尝试重用相同的连接。所以,我得到EOFException类。

My proxy closes the connection but my code still tries to reuse the same connection. And so I get EOFException.

我如何处理这类案件?

推荐答案

我会建议禁用http.keepalive系统属性。在文档的性能部分表示套接字连接将被重用时可能。这听起来就像是试图重用连接,但代理已经关闭了它。在这个帖子,达雷尔还表明,改变系统特性解决了他的问题。

I'd recommend disabling the http.keepalive system property. The performance section of the documentation indicates that socket connections will be reused when possible. It sounds like it is trying to reuse the connection, but the proxy has already closed it. On this post, Darrell also indicates that changing the system property solved his problem.

System.setProperty("http.keepAlive", "false");

这篇关于Android的HttpURLConnection的抛EOFException类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆