By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

WebClient Timeout Exception

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.