HttpClient在成功执行的方法上挂起在socketRead0上 [英] HttpClient hangs on socketRead0 with successfully executed method

查看:969
本文介绍了HttpClient在成功执行的方法上挂起在socketRead0上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的网络应用程序中,用户可以提交网址。我们将获取数据并解析服务器端。对于每个请求,我们使用具有以下(相关)设置的HttpClient

In our web-application A user can submit a url. We will fetch the data and parse it server side. For each request we use an HttpClient with the following (relevant) settings

connectionManager.getParams().setConnectionTimeout(10000);
connectionManager.getParams().setSoTimeout(10000);

当我调用HttpMethod.getResponseBody时,状态代码已被检查为可接受。此时线程挂起此堆栈跟踪:

When I call HttpMethod.getResponseBody the status code has already been checked to be acceptable. At this point the thread hangs with this stack trace:

java.net.SocketInputStream.socketRead0 ( native code )
java.net.SocketInputStream.read ( SocketInputStream.java:150 )
java.net.SocketInputStream.read ( SocketInputStream.java:121 )
java.io.BufferedInputStream.read1 ( BufferedInputStream.java:273 )
java.io.BufferedInputStream.read ( BufferedInputStream.java:334 )
java.io.FilterInputStream.read ( FilterInputStream.java:133 )
org.apache.commons.httpclient.AutoCloseInputStream.read ( AutoCloseInputStream.java:108 )
java.io.FilterInputStream.read ( FilterInputStream.java:107 )
org.apache.commons.httpclient.AutoCloseInputStream.read ( AutoCloseInputStream.java:127 )
org.apache.commons.httpclient.HttpMethodBase.getResponseBody ( HttpMethodBase.java:690 )

I无法找到发生这种情况的确切网址(这是一个在实时环境中发生的事件)而且我无法重现i吨。我想这只是我们所连接的服务器的一个问题,表现得很奇怪,但也许我错过了一些东西。在任何一种情况下,有没有办法让我阻止阻塞方法调用永远等待? SoTimeout也是套接字读取超时?是否还有其他设置我缺席了?

I cannot discover the exact URL for which this happened (was an incident on a live environment) and I have been unable to reproduce it. I'd like to think it's simply a matter of the server we're connecting to behaving strangely, but perhaps I'm missing something. In either case, is there a way for me to prevent the blocking method call from waiting forever? The SoTimeout is also the socket read timeout? Is there another setting I'm missing?

推荐答案

我已将所有超时设置得很好但我发现我们已经在网址上了做http分块但没有发送结果(在chrome中工作正常,但在http客户端,即使设置了超时,它也会永久挂起)。幸运的是,我拥有服务器,只是返回一些垃圾,它不再挂起。这似乎是一个非常独特的错误,http客户端不能很好地处理某种空的分块情况(虽然我可能会离开)....我只是知道它每次挂在同一个网址上的空数据和该网址是http chunking csv下载回我们的http客户端。

I have all the timeouts setup just fine but I found out we have on url that does http chunking but sends no results(works fine in chrome, but in http client it hangs forever even with the timeout set). Luckily I own the server and just return some garbage and it no longer hangs. This seems like a very unique bug in that http client does not handle some kind of empty chunking case well(though I could be way off)....I just know it hangs every time on that same url with empty data and that url is http chunking csv download back to our http client.

这篇关于HttpClient在成功执行的方法上挂起在socketRead0上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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