HttpClient 在收到服务器响应之前自动退出

发布于 2024-08-25 04:21:59 字数 254 浏览 3 评论 0原文

我遇到了 java HttpClient 库的一个奇怪问题。 具体来说,库会自动重试我的请求(POST 请求) 甚至在从服务器收到响应之前。还有更奇怪的问题 是这只发生在特定主机(机器)上。

所以最终的结果是如果post请求成功,那么可能会有一模一样的 发送到服务器但服务器无法处理的请求。现在,我确实想要 重试行为,但它应该表现得直观。
有没有人遇到过这种问题,或者有什么办法可以配置 http 客户端在重试之前等待特定时间。我不知道会发生什么 这里错了。

I'm come upon a wierd problem with java HttpClient library.
Specifically the library automatically retries my request (POST requests)
even before the response is received from the server. Moreover the weirder problem
is that this only happens on specific hosts (machines).

So the end result is if a post request succeeds, then there may be an exact same
post request coming to the server which the server can't handle. Now, I do want
the retry behavior, but it should behave intuitively.
Anyone faced this kind of problem before, or is there a way to configure
http client to wait for a specific time before retrying. I'm not sure what going
wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风无影 2024-09-01 04:21:59

您是否为 HttpClient 设置了 methodretryhandler?如:

DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler(10, true);
client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);

这就是重试的起始位置,您可以调试并查看它收到的响应标头(如果有)等。

您是否尝试过使用 firefox http 监视器或 ethereal 或类似的工具来查看您的 http 请求和响应,并确保您收到的内容相信正在发生的事情真的正在发生吗?

Do you have a methodretryhandler set for your HttpClient? As in:

DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler(10, true);
client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);

That is where retries would originate and you could debug and see what response headers it's receiving if any, etc.

Have you tried using a firefox http monitor or ethereal or similar to look through your http requests and responses and ensure that what you believe is happening is actually hapening?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文