473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

System.Net.WebException: The operation has timed-out

I am performing several httpwebrequest and webresponse operations to download some wav files.

I included the sample code below. When I execute these commands they work for a while and then
5 - 50 minutes into doing its thing i will start to get errors like:

System.Net.WebException: The operation has timed-out

My function I call is GetWaveFile(Wav9,"Wav9",sFileName);

it is in a service that grabs a different wav file every 5 seconds, and the full code is below:
I do close the response below, but not quite sure whats going on, and its really boggling me.

public static void GetWaveFile(string sURL, string sType, string sFileName)
{

HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create(sURL);

HttpWReq.Method = "GET";

HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWReq.GetResponse();

StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream());
FileStream fs = new FileStream("d:/Files/" + sType + sFileName + ".wav",System.IO.FileMode.Create);

BinaryWriter w = new BinaryWriter(fs);
BinaryReader r = new BinaryReader(sr.BaseStream);

byte[] data = r.ReadBytes(300000);

w.Write(data);
HttpWResponse.Close();

}

Nov 16 '05 #1
1 2266
michin1@yahoonospam wrote:
I am performing several httpwebrequest and webresponse operations to
download some wav files.

I included the sample code below. When I execute these commands they
work for a while and then 5 - 50 minutes into doing its thing i will
start to get errors like:

System.Net.WebException: The operation has timed-out

My function I call is GetWaveFile(Wav9,"Wav9",sFileName);

it is in a service that grabs a different wav file every 5 seconds,
and the full code is below:
I do close the response below, but not quite sure whats going on, and
its really boggling me.

public static void GetWaveFile(string sURL, string sType, string
sFileName) {

HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create(sURL);

HttpWReq.Method = "GET";

HttpWebResponse HttpWResponse =
(HttpWebResponse)HttpWReq.GetResponse();

StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream());
FileStream fs = new FileStream("d:/Files/" + sType + sFileName +
".wav",System.IO.FileMode.Create);

BinaryWriter w = new BinaryWriter(fs);
BinaryReader r = new BinaryReader(sr.BaseStream);

byte[] data = r.ReadBytes(300000);

w.Write(data);
HttpWResponse.Close();

}


Um... your IO code is somewhat questionable. You're using BinaryReader and
BinaryWriter which are just overhead in this context, you create a junk
StreamReader instance, you cannot handle files bigger than 300000 bytes and
you never close your Writer or output stream. I suggest fixing the obvious
problems and then retest your application.

Cheers,

--
Joerg Jooss
jo*********@gmx.net

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan Crowther | last post by:
On one PC the following test code results in an error on the GetResponse line while it works OK on another PC. The only difference that I am aware of is that the one that works is XP while the...
1
by: Sean Erwin | last post by:
I am having a very frustrating intermittent problem. I am making an A2A call to a remote server and when I issue the: WebRequest.getResponse call it occasionally fails with the following error: ...
2
by: genc_ ymeri at hotmail dot com | last post by:
Hi, I'm trying to recieve the response status code rather than the message in the below code : try { responseArray = myWebClient.UploadValues(uriString,"POST",myNameValueCollection); }...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
0
by: Faiyaz | last post by:
Hello to EveryBody i'm Getting this Peculiar error System.ApplicationException: The remote server returned an error (400) Bad Request. - - > System.Net.WebException: The remote server...
1
by: Tim Reynolds | last post by:
Team, From a windows service, we consume a web service on another server and occasionally receive System.Net.WebException: The underlying connection was closed:. For some clients we call, we do...
8
by: Tim Reynolds | last post by:
Our .Net application calls a web method of aplpication 2 that resides on their Apache server. When I as a developer C#, Studios 2003, make the call to their web method from my desktop, I receive no...
0
by: Seth Thibodeaux | last post by:
I have built a Windows Service that connects to Sql Server 2000 Reporting Services via its Web Service interface for the purpose of generating reports. Intermittently, calls made to the Web Service...
2
by: Scott McFadden | last post by:
When I invoke two web service methods sequentially with no delay, the first web method invocation goes smooth while the 2nd one generates the dredded: System.Net.WebException: The underlying...
3
sid0404
by: sid0404 | last post by:
Hi I am new to the programming in c#, I have an application where I need to get data from a website now I am getting an error message if I give the input as two strings, say Sun Microsystems while...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.