The HTTP request is being made against a Live365-based audio streamer (MP3 streamer) and the code below hangs every time I run it. The stream it is opening is thus very large and is binary rather than textual - but in the example code below I don't even read any of that stream.
The code does not hang under full .NET running on my XP box.
Can anyone suggest a solution or workaround for this
Thanks
Stuart
Code is:
string inputURL = "http://216.235.81.3:20012";
WebResponse response = null; Uri myUri = new Uri(inputURL, UriKind.Absolute);
WebRequest req = WebRequest.Create(myUri);
response = req.GetResponse();
if (response != null)
{
// this line hangs :-(
response.Close();
}

WebResponse Close call hangs
briankerri
therock
Using the WinPCAPs Analyzer tool I see the following type of trace - with the data transfer continuing until I use Task manager to stop the test application.
Dan1
In this specific case, even though the client looks like its hung its actually draining the socket stream which takes a long time (took me somthing like an hour).
You can speed this up by reading the data in the application passing in a large buffer.
Thanks,
Sandy
deepakleo2003
I've tried the workaround you suggested using the loop:
Stream s = response.GetResponseStream(); byte[] buffer = new byte[100000]; while (true)
{
if (s.Read(buffer, 0, 100000) <= 0){
break;}
}
- but it still takes an excessive length of time to complete - to the appearance of my UI thread it does seem to "hang".
I've also tried using the asynchronous .BeginGetResponse and .BeginRead APIs but these still don't seem to help speed up the shutdown of the transfer either.
Are there any other suggestions you can provide about how to speed this up Specifically is there any way I can just abandon the data transfer - that I can close the underlying socket and move on without transferring the entire file
Thanks again for your help so far.
Stuart
Scoper
Would it be possible to capture packet traces using a network sniffer like ethereal and provide that capture here It would be very useful in debugging the issue.
Does this happen only on an emulator or does it also occur when you deploy to a device
Thanks,
Sandy
Sverk
The answer from MS was that this is a feature.
I ended up writing my own little HTTP stack so that I could cancel it when I wanted to.... and I'm still fixing bugs and issues in the stack :-/
Good luck!
Richard Masse
HttpWebRequest.Abort() does not work. Setting the Request = null does not work. Closing the response does not work. Closing the stream does not work. Once you've gotten that responseStream you are going to hang until the entire file transfers down. How the heck do you CANCEL it I don't want it. I want the thing to die!
Kakurady