|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Timeout in HttpWebRequest.GetResponse() for large uploadsserver. The data files can potentially be 20mb or more. The relevant code for this looks essentially like: Stream reqStream = request.GetRequestStream(); reqStream.Write(data, 0, data.Length); reqStream.Close(); WebResponse response = request.GetResponse(); My problem is that GetResponse() times out while the file is being uploaded. My call to Write() is returning immediately rather than blocking until the data gets sent to the remote server. I know I can increase the timeout interval but that just pushes out the upper size limit for data without fixing the real issue. I've found that if I upload in pieces instead of writing the data all at once then every call to Write after the first one seems to block while data from the previous write gets uploaded. That potentially solves my problem since only the last, small piece will be left when I call GetResponse. I can't find any documentation confirming this behavior, though. Is there any guarantee that if I upload in pieces then my program can more or less monitor the actual transfer progress. If not, does anyone have other ideas how I can avoid calling GetResponse() until the upload is finished? Thanks, Ravi. Please try asynchronous request HttpWebRequest.BeginGetResponse
http://www.alvas.net - Audio tools for C# and VB.Net developers Show quote "Ravi" <ravi.use***@gmail.com> ???????/???????? ? ???????? ?????????: news:091fb38d-9b0c-4550-ab83-e4b09317123a@b15g2000hsa.googlegroups.com... > I'm using HttpWebRequest in .NET 1.1 to post data files to a web > server. The data files can potentially be 20mb or more. The relevant > code for this looks essentially like: > > Stream reqStream = request.GetRequestStream(); > reqStream.Write(data, 0, data.Length); > reqStream.Close(); > WebResponse response = request.GetResponse(); > > My problem is that GetResponse() times out while the file is being > uploaded. My call to Write() is returning immediately rather than > blocking until the data gets sent to the remote server. I know I can > increase the timeout interval but that just pushes out the upper size > limit for data without fixing the real issue. > > I've found that if I upload in pieces instead of writing the data all > at once then every call to Write after the first one seems to block > while data from the previous write gets uploaded. That potentially > solves my problem since only the last, small piece will be left when I > call GetResponse. > > I can't find any documentation confirming this behavior, though. Is > there any guarantee that if I upload in pieces then my program can > more or less monitor the actual transfer progress. If not, does anyone > have other ideas how I can avoid calling GetResponse() until the > upload is finished? > > Thanks, > Ravi. |
|||||||||||||||||||||||