473,394 Members | 2,168 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,394 software developers and data experts.

WebClient Timeout Exception

I have a problem with the WebClient and uploading a file to a web server. The
stream object returned from the WebClient.OpenWrite menthod throws a timeout
exception when using this method on computers w/ low bandwith ( < = 256 kbs).
The exception occurs when I call the Stream.Close method. Here is the code:

WebClient client = new WebClient();
Stream postStream = client.OpenWrite(uri,"PUT");
postStream.Write(buffer, 0, buffer.Length);
postStream.Flush();
postStream.Close();

Buffer length is around 4 MB. The code shown is from a Windows App that
consumes a web service. I have tried several approaches, but haven't found a
working solution, such as..

Writing a 2k chunk and calling flush until the entire buffer is read
Writing a webservice method that takes an array of bytes

Any suggestions would be extremely helpful
Thanks in advance

Nov 16 '05 #1
3 15072
I didn't know about the web.mail namespace back when I needed to send email,
the link below is a very simple example of how to send email with C#. I have
been using this for sometime with out issues. If all else fails you could
try it out.

http://www.codeproject.com/csharp/sendmailcsharp.asp

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Michael Fields" <Michael Fi****@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
I have a problem with the WebClient and uploading a file to a web server. The stream object returned from the WebClient.OpenWrite menthod throws a timeout exception when using this method on computers w/ low bandwith ( < = 256 kbs). The exception occurs when I call the Stream.Close method. Here is the code:
WebClient client = new WebClient();
Stream postStream = client.OpenWrite(uri,"PUT");
postStream.Write(buffer, 0, buffer.Length);
postStream.Flush();
postStream.Close();

Buffer length is around 4 MB. The code shown is from a Windows App that
consumes a web service. I have tried several approaches, but haven't found a working solution, such as..

Writing a 2k chunk and calling flush until the entire buffer is read
Writing a webservice method that takes an array of bytes

Any suggestions would be extremely helpful
Thanks in advance

Nov 16 '05 #2
The problem is not trying to send email. Here is the scenerio. A C# windows
app needs to upload a file to a webserver. Its 4 MB zip file.

"Wayne" wrote:
I didn't know about the web.mail namespace back when I needed to send email,
the link below is a very simple example of how to send email with C#. I have
been using this for sometime with out issues. If all else fails you could
try it out.

http://www.codeproject.com/csharp/sendmailcsharp.asp

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Michael Fields" <Michael Fi****@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
I have a problem with the WebClient and uploading a file to a web server.

The
stream object returned from the WebClient.OpenWrite menthod throws a

timeout
exception when using this method on computers w/ low bandwith ( < = 256

kbs).
The exception occurs when I call the Stream.Close method. Here is the

code:

WebClient client = new WebClient();
Stream postStream = client.OpenWrite(uri,"PUT");
postStream.Write(buffer, 0, buffer.Length);
postStream.Flush();
postStream.Close();

Buffer length is around 4 MB. The code shown is from a Windows App that
consumes a web service. I have tried several approaches, but haven't found

a
working solution, such as..

Writing a 2k chunk and calling flush until the entire buffer is read
Writing a webservice method that takes an array of bytes

Any suggestions would be extremely helpful
Thanks in advance


Nov 16 '05 #3
Gee I was wondering why this didn't show up under the email topic I read the
other day. Sorry, must of had the wrong item highlighted when I hit reply,
or work got in the way and distracted me.

Wayne
"Michael Fields" <Mi***********@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
The problem is not trying to send email. Here is the scenerio. A C# windows app needs to upload a file to a webserver. Its 4 MB zip file.

"Wayne" wrote:
I didn't know about the web.mail namespace back when I needed to send email, the link below is a very simple example of how to send email with C#. I have been using this for sometime with out issues. If all else fails you could try it out.

http://www.codeproject.com/csharp/sendmailcsharp.asp

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Michael Fields" <Michael Fi****@discussions.microsoft.com> wrote in message news:29**********************************@microsof t.com...
I have a problem with the WebClient and uploading a file to a web server.
The
stream object returned from the WebClient.OpenWrite menthod throws a

timeout
exception when using this method on computers w/ low bandwith ( < =
256 kbs).
The exception occurs when I call the Stream.Close method. Here is the

code:

WebClient client = new WebClient();
Stream postStream = client.OpenWrite(uri,"PUT");
postStream.Write(buffer, 0, buffer.Length);
postStream.Flush();
postStream.Close();

Buffer length is around 4 MB. The code shown is from a Windows App
that consumes a web service. I have tried several approaches, but haven't

found a
working solution, such as..

Writing a 2k chunk and calling flush until the entire buffer is read
Writing a webservice method that takes an array of bytes

Any suggestions would be extremely helpful
Thanks in advance


Nov 16 '05 #4

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

Similar topics

9
by: Kueishiong Tu | last post by:
I am using webclient to retrieve data from a web site. How do I control the time-out of this request?
11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
2
by: Crirus | last post by:
How can I change a WebClient timeout in order to allow more time to a server to respond -- Cheers, Crirus ------------------------------ If work were a good thing, the boss would take it...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
4
by: Natalia | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great...
2
by: Ezequiel | last post by:
Hi, I´m coding an application that is able to download various mp3 files at the same time. For each mp3 download i´m using a thread. Each thread uses System.net.WebClient. If i try to download 3...
0
by: Yet Another One | last post by:
Hello, I am using System.Net.WebClient() to download a web page. This works fine in itself, BUT... if there is no response from the web site or if my network is down, it NEVER times out trying...
1
by: Macneed | last post by:
i am a newbie, i want to write a code to download data from web using webclient string HTMLstring = ""; WebClient client = new WebClient(); Byte HP =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.