为什么我会收到错误“底层连接已关闭” 当获取图像时?

发布于 2024-07-29 06:01:29 字数 754 浏览 1 评论 0原文

我正在使用一些代码来获取给定 URL 的图像,它对我尝试过的所有 URL 都有效,除了一个:

http://title.mximg.com/img/logo/bizrealty.com.gif

对于此 URL,我收到“底层连接已关闭:接收时发生意外错误” ”。

但是,如果您使用浏览器打开该 URL,它会完美加载。

显然该错误消息的含义是:

“底层连接已关闭: 发生意外错误 接收。”
--当客户端发送完整的请求并获得 TCP 时看到 来自服务器的 ACK-FIN 或 RST 关闭 连接,无响应 来自服务器。

但我不知道这意味着什么:-(

代码很简单:

Dim req As System.Net.HttpWebRequest = DirectCast(WebRequest.Create(ImageURL), HttpWebRequest)
req.Method = "GET"
Dim resp As Net.HttpWebResponse = DirectCast(req.GetResponse(), Net.HttpWebResponse)

更新:将 KeepAlive 设置为 false 没有帮助。另外,这不是超时问题,我很快就收到错误。

知道可能是什么发生什么事了?
谢谢!

I'm using a little code to grab an image given its URL, and it's working for me for all URLs I tried except one:

http://title.mximg.com/img/logo/bizrealty.com.gif

For this URL, I'm getting "The underlying connection was closed: An unexpected error occurred on a receive."

However, if you open that URL with a browser, it loads perfectly.

Apparently that error message means:

"The underlying connection was closed:
An unexpected error occurred on a
receive."
--Seen when the client had sent the request in its entirety and got a TCP
ACK-FIN or RST from server to close
the connection, without a response
from server.

But I have no idea what that means :-(

The code is simply:

Dim req As System.Net.HttpWebRequest = DirectCast(WebRequest.Create(ImageURL), HttpWebRequest)
req.Method = "GET"
Dim resp As Net.HttpWebResponse = DirectCast(req.GetResponse(), Net.HttpWebResponse)

UPDATE: Setting KeepAlive to false doesn't help it. Also, it's not a timeout issue, I'm getting the error quite fast.

Any idea what could be going on?
Thanks!

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

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

发布评论

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

评论(1

白况 2024-08-05 06:01:29

我会尝试更新您的请求设置,例如 UserAgent 或接受。 他们可能会动态提供图像并拒绝看起来不像正常流量的请求。

I'd try updating your request settings like UserAgent or Accept. It's possible they're serving images dynamically and reject requests that don't look like normal traffic.

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