避免远程服务器 .NET 上的 504

发布于 2024-08-10 10:38:01 字数 179 浏览 2 评论 0原文

我正在使用 HttpWebRequest 下载远程文件,但是收到 504 错误。 我将网址粘贴到 Firefox 中,第一次和第三次尝试花了 16 秒,第二次什么也没发生(看起来超时了)。

如何减少 504 错误?更改 HttpWebRequest 超时有帮助吗?如果收到 504 错误,我应该尝试重试该文件(假设 3 次)吗?

I am using HttpWebRequest to download a remote file, however i get a 504 error.
I pasted the url in firefox and the first and 3rd try it took 16seconds, the 2nd nothing happened (it looked like it timed out).

How do i decrease the 504 error? Would changing HttpWebRequest timeout help? should i attempt to retry the file (lets say 3 times) if i receive a 504 error?

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

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

发布评论

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

评论(3

晚雾 2024-08-17 10:38:01

那是服务器问题。你没有办法阻止这种情况。我会重试几次,在中间添加一些 Thread.Sleep 。

That's a server problem. There's no way for you to prevent that. I would retry a couple of times adding some Thread.Sleep in between.

自由如风 2024-08-17 10:38:01

5xx 是服务器错误。查看响应的实体主体,看看服务器是否给出了任何关于发生这种情况的原因的提示。

您可以通过从 WebException 对象获取 Response 来获取实体主体。

5xx is a server error. Look at the entity body of the response to see if the server gives any hint as to why this is happening.

You can get the entity body by getting the Response from the WebException object.

や三分注定 2024-08-17 10:38:01

尝试在 POST 请求正文末尾添加 &

variable=value&

也许服务器正在等待 POST 数据。

Try putting an & at the end of your POST request body:

variable=value&

Maybe the server is waiting for POST data.

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