简体   繁体   English

为什么我的 HTTPPost 会收到 404 响应?

[英]Why is my HTTPPost getting a 404 response?

I'm using org.apache.http.client.methods.HttpPost to send data to a verified URL.我正在使用 org.apache.http.client.methods.HttpPost 将数据发送到经过验证的 URL。 My client works on some systems but not others.我的客户在某些系统上工作,但在其他系统上不工作。 I've verified the URL I'm attempting to access from my JAVA code is accessible from the client's systems using a web browser.我已经验证了我尝试从我的 JAVA 代码访问的 URL 可以使用 Web 浏览器从客户端的系统访问。 The really strange thing is there is no record of the POST coming into Tomcat when I review the Tomcat access logs.真正奇怪的是,当我查看Tomcat访问日志时,没有任何POST进入Tomcat的记录。

My only guess at this point is the client side systems are using some type of application level firewall.在这一点上,我唯一的猜测是客户端系统正在使用某种类型的应用程序级防火墙。 I'm still looking into that possibility.我仍在研究这种可能性。

Can anyone think of any other possible reasons why I'd be getting a 404 response without a record of the request in the Tomcat 8 access logs?谁能想到为什么我会得到 404 响应而没有在 Tomcat 8 访问日志中记录请求的任何其他可能原因?

Thanks!谢谢!

I figured it out about an hour after I posted this question.我在发布这个问题后大约一个小时想通了。 Our System Administrator updated the DNS record the HTTP clients were attempting to connect to.我们的系统管理员更新了 HTTP 客户端尝试连接的 DNS 记录。 The DNS update pointed to a Application server that did not host the webapp the client was trying to communicate with. DNS 更新指向的应用程序服务器没有托管客户端试图与之通信的 web 应用程序。

While the DNS record was invalid he restarted all of the HTTP client services and when they tried to connect to the webapp the clients got a 404 response.当 DNS 记录无效时,他重新启动了所有 HTTP 客户端服务,当他们尝试连接到 web 应用程序时,客户端收到了 404 响应。

Once I figured out there was something wrong with the DNS record and had him correct the IP that's when we started seeing the topic in question.当我发现 DNS 记录有问题并让他更正 IP 后,我们才开始看到有问题的主题。

It turns out when the HTTPClient receives a 404 response, it no longer attempts to bind to the URL until the client service is restarted or a new HTTPClient instance is created.事实证明,当 HTTPClient 收到 404 响应时,它不再尝试绑定到 URL,直到客户端服务重新启动或创建新的 HTTPClient 实例。

Here's my client code...这是我的客户端代码...

CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("UN", "PW"));         
HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();

Can someone provide me with sample code to force the org.apache.http.client.HttpClient to check for a resource despite any prior 404 responses?有人可以向我提供示例代码以强制 org.apache.http.client.HttpClient 尽管有任何先前的 404 响应而检查资源吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM