WebRequest - large files - timeout problem.

P

Piotrekk

Hi

I am trying to upload a 700 mb file using webrequest/response model.
At 3x% I am getting the same error:

"Unable to write data to the transport connection: an established
connection was aborted by the software in your host machine"

CLIENT side script is:

req = WebRequest.Create(
req.Method = "POST";

//Headers
req.ContentType = "multipart/form-data";
req.ContentLength = fileSize;
req.Headers.Add("Name", file.Name);
req.Headers.Add("Path", path);
req.Headers.Add("SessionID", session);
req.Timeout = int.MaxValue;

Stream stream = req.GetRequestStream();

using (BinaryWriter writer = new BinaryWriter(stream))
{
FileStream fs = new FileStream(file.FullName,
FileMode.Open);

using (BinaryReader reader = new BinaryReader(fs))
{
int i = 0;
long total = 0;

byte[] buffer = new byte[32768];

while (((i = reader.Read(buffer, 0,
buffer.Length)) > 0) && !Stop)
{
writer.Write(buffer, 0, i);
total += i;
uploadWorker.ReportProgress((int)(total *
100 / fileSize));
}
}
}





SERVER side script is:

Stream inputStream = HttpContext.Current.Request.InputStream;

using (BinaryReader reader = new
BinaryReader(inputStream))
{
FileStream fs = new FileStream(fullfile,
FileMode.Create);

using (BinaryWriter writer = new
BinaryWriter(fs))
{
int i = 0;
byte[] buffer = new byte[32768];

while ((i = reader.Read(buffer, 0,
buffer.Length)) > 0)
{
writer.Write(buffer, 0, i);
}
}
}

Server has <httpRuntime maxRequestLength="102400" /> in its config
file.

Would be grateful for help.
Kind Regards
PK
 
U

Udo Nesshoever

Piotrekk said:
I am trying to upload a 700 mb file using webrequest/response model.
At 3x% I am getting the same error:

"Unable to write data to the transport connection: an established
connection was aborted by the software in your host machine"
Server has <httpRuntime maxRequestLength="102400" /> in its config
file.

Increase that value. It represents the maximum data amount that can be
uploaded in kB. Your maximum therefore is 100MB which doesn't quite
cover your 700mb ;)

Cheers,
Udo
 
I

Ignacio Machin ( .NET/ C# MVP )

I think you should find another way to upload such a big file, IIRC
the maximum size for ASPNET is like 100MB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top