任何人都可以提出获得NoHttpResponseException的原因吗? 我的应用程序不断从服务中收到此异常。这是客户端问题还是服务器端?
如何使用这些问题进行调试?
以下是相同
的堆栈跟踪[Thread-2] INFO(com.amazonaws.http.AmazonHttpClient executeHelper:581) - 无法执行HTTP请求:sqs.ap-southeast-1.amazonaws.com:443无法响应 org.apache.http.NoHttpResponseException:sqs.ap-southeast-1.amazonaws.com:443未能回复 at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:143) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) 在org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283) at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:259) at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:209) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) 在com.amazonaws.http.protocol.SdkHttpRequestExecutor.doReceiveResponse(SdkHttpRequestExecutor.java:66) 在org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:686) 在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:488) 在org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884) 在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) 在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) 在com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:819) 在com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:574) 在com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:362) 在com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:328) 在com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:307) 在com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2419) 在com.amazonaws.services.sqs.AmazonSQSClient.deleteMessage(AmazonSQSClient.java:1472) 在com.micromax.datasets.queue.SQSPoller.pullJsonFromQueue(SQSPoller.java:142) 在com.micromax.datasets.scheduler.MultiQueuePull.run(MultiQueuePull.java:28) 在java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:1)
如https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html中所定义:
Client Error 4xx
The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user.
If the client is sending data, a server implementation using TCP SHOULD be careful to ensure that the client acknowledges receipt of the packet(s) containing the response, before the server closes the input connection. If the client continues sending data to the server after the close, the server's TCP stack will send a reset packet to the client, which may erase the client's unacknowledged input buffers before they can be read and interpreted by the HTTP application.
基本上,这意味着每个4xx都是来自客户端的错误。但是443没有在HTTP标准中定义,因此您应该在服务的文档中搜索它是否可用
答案 1 :(得分:0)
来自Apache docs:
<块引用>在某些情况下,通常在负载较重的情况下,Web 服务器可能能够接收请求但无法处理它们。缺乏足够的资源(如工作线程)就是一个很好的例子。这可能会导致服务器断开与客户端的连接而不给出任何响应。 HttpClient 遇到这种情况会抛出 NoHttpResponseException。
这个问题很可能是由服务引起的,而不是由客户端引起的。您可以尝试通过其他方式联系该服务来确认这一点,例如在浏览器中访问其网址或使用终端中的 curl
工具。