WebRequest - large files - timeout problem.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Piotrekk

    WebRequest - large files - timeout problem.

    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.Crea te(
    req.Method = "POST";

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

    Stream stream = req.GetRequestS tream();

    using (BinaryWriter writer = new BinaryWriter(st ream))
    {
    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(buf fer, 0,
    buffer.Length)) 0) && !Stop)
    {
    writer.Write(bu ffer, 0, i);
    total += i;
    uploadWorker.Re portProgress((i nt)(total *
    100 / fileSize));
    }
    }
    }





    SERVER side script is:

    Stream inputStream = HttpContext.Cur rent.Request.In putStream;

    using (BinaryReader reader = new
    BinaryReader(in putStream))
    {
    FileStream fs = new FileStream(full file,
    FileMode.Create );

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

    while ((i = reader.Read(buf fer, 0,
    buffer.Length)) 0)
    {
    writer.Write(bu ffer, 0, i);
    }
    }
    }

    Server has <httpRuntime maxRequestLengt h="102400" /in its config
    file.

    Would be grateful for help.
    Kind Regards
    PK
  • Udo Nesshoever

    #2
    Re: WebRequest - large files - timeout problem.

    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 maxRequestLengt h="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

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: WebRequest - large files - timeout problem.

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

      Comment

      Working...