Java 代理错误 502:代理服务器收到来自上游服务器的无效响应

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20406845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:44:03  来源:igfitidea点击:

Proxy Error 502 : The proxy server received an invalid response from an upstream server

javaemailproxytomcat6

提问by Ranjeet Ranjan

We are building a mass mailing sending application in Java. Mail is being send by third party SMTP. After sending 400-500 mails tomcat6 service get stopped. Below is the error.

我们正在用 Java 构建一个群发邮件发送应用程序。邮件正由第三方 SMTP 发送。发送 400-500 封邮件后 tomcat6 服务停止。下面是错误。

Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /lin/Campaignn.jsp. Reason: Error reading from remote server

代理错误代理服务器收到来自上游服务器的无效响应。代理服务器无法处理请求 GET /lin/Campaignn.jsp。原因:从远程服务器读取错误

Additionally, a 502 Bad Gateway error was encountered while trying to use an ErrorDocument to handle the request.

此外,在尝试使用 ErrorDocument 处理请求时遇到 502 Bad Gateway 错误。

Apache Server at msizzler.com Port 80

msizzler.com 端口 80 上的 Apache 服务器

But when we are sending from localhost I did not received any error. It send all the mails. Please help me to sort it out this problem.

但是当我们从本地主机发送时,我没有收到任何错误。它发送所有邮件。请帮我解决这个问题。

回答by rmeakins

The HTTP 502 "Bad Gateway" response is generated when Apache web server does not receive a valid HTTP response from the upstream server, which in this case is your Tomcat web application.

当 Apache Web 服务器未从上游服务器(在本例中是您的 Tomcat Web 应用程序)接收到有效的 HTTP 响应时,会生成 HTTP 502“Bad Gateway”响应。

Some reasons why this might happen:

可能发生这种情况的一些原因:

  • Tomcat may have crashed
  • The web application did not respond in time and the request from Apache timed out
  • The Tomcat threads are timing out
  • A network device is blocking the request, perhaps as some sort of connection timeout or DoS attack prevention system
  • Tomcat 可能已经崩溃
  • Web 应用程序没有及时响应,来自 Apache 的请求超时
  • Tomcat 线程超时
  • 网络设备阻止请求,可能是某种连接超时或 DoS 攻击预防系统

If the problem is related to timeout settings, you may be able to resolve it by investigating the following:

如果问题与超时设置有关,您可以通过调查以下内容来解决它:

回答by Albert Maclang

Add this into your httpd.conf file

将此添加到您的 httpd.conf 文件中

Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore 

回答by Anthony Hunt

The java application takes too long to respond(maybe due start-up/jvm being cold) thus you get the proxy error.

java 应用程序需要很长时间才能响应(可能是由于启动/jvm 很冷),因此您会收到代理错误。

Proxy Error

The proxy server received an invalid response from an upstream server.
 The proxy server could not handle the request GET /lin/Campaignn.jsp.

As Albert Maclang said amending the http timeout configuration may fix the issue. I suspect the java application throws a 500+ error thus the apache gateway error too. You should look in the logs.

正如 Albert Maclang 所说,修改 http 超时配置可能会解决这个问题。我怀疑 java 应用程序抛出 500+ 错误,因此 apache 网关错误。你应该查看日志。

回答by CincyBella

I had this issue once. It turned out to be database query issue. After re-create tables and index it has been fixed.

我曾经遇到过这个问题。原来是数据库查询问题。重新创建表和索引后,它已被修复。

Although it says proxy error, when you look at server log, it shows execute query timeout. This is what I had before and how I solved it.

虽然它说代理错误,但当您查看服务器日志时,它显示执行查询超时。这是我以前遇到的以及我如何解决它的。