【问题标题】:Reason for NoHttpResponseExceptionNoHttpResponseException 的原因
【发布时间】:2017-11-20 07:59:31
【问题描述】:

任何人都可以提出得到 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 未能响应 在 org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:143) 在 org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) 在 org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) 在 org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283) 在 org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:259) 在 org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:209) 在 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) 在 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)

【问题讨论】:

  • 您确定状态码吗?不是SSL连接的端口吗?
  • 您能否显示异常并命名您正在使用的技术?也许显示您的应用程序的代码?可能是error id
  • 我猜它的端口,对不起我的误导!
  • @JazZ 从堆栈跟踪中你有什么看法?

标签: http http-status-codes


【解决方案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 标准中没有定义,所以你应该在服务的文档中搜索它是否可用

【讨论】:

  • 日志中看到的 443 不是 HTTP 状态代码,而是 HTTPS 的 port number
【解决方案2】:

来自Apache docs

在某些情况下,通常在负载较重的情况下,Web 服务器可能能够接收请求但无法处理它们。缺乏足够的资源(如工作线程)就是一个很好的例子。这可能会导致服务器断开与客户端的连接而不给出任何响应。 HttpClient遇到这种情况会抛出NoHttpResponseException。

这个问题很可能是由服务引起的,而不是由客户端引起的。您可以尝试通过其他方式联系服务来确认这一点,例如在浏览器中访问其 url 或使用终端中的curl 工具。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-13
    • 2017-04-10
    • 1970-01-01
    • 2014-05-31
    • 2015-12-30
    • 1970-01-01
    • 2011-07-30
    • 2014-10-17
    相关资源
    最近更新 更多