I am using HttpWebRequest to connect to a URL. This url keeps the connection open so that it can pump the data to the client over the internet. A custom 开发者_如何转开发pub/sub if you will.
It is a simple GET.
The response headers I get looks something like this:
HTTP/1.1 200 OK
Connection: close
Date: Tue, 09 Nov 2010 23:02:11 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: text/html; charset=utf-8
Anyway, when I call HttpWebResponse.Close() on the client, the call hangs indefinitely. I do get disconnected but only when the server aborts the connection.
I tried various settings on the request object and ServicePoint, etc. with little luck.
Any idea how I can close these connections from the client side without getting hung?
Try calling .Abort()
on the HttpWebRequest
object just prior to calling .Close()
on the HttpWebResponse
.
精彩评论