You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Steve Fyfe <SD...@cnicorp.com> on 2000/07/17 23:33:01 UTC

[BUG] Network connection reset while uploading large file

I have discovered that when I attempt to upload a file larger than 40KB, Tomcat will just reset the network connection. As a result, IE shows an error screen with the message "Server or DNS not available", and Netscape gives an error message box saying "A network error has occurred while sending data (Connection reset by peer)."

 Whenever I send a file that is smaller than 40KB, the response produced by the test servlet is correctly shown in the browser's window. But if I upload a file larger than 40KB using the exact same configuration and servlet, the code in the servlet is executed but the web page produced by the servlet never appears - the browser's error message appears instead.

This problem occurs both when I run Tomcat locally (Win 98) and when I run it on NT 4 with IIS serving the static pages. I get the same problem using Tomcat 3.1 or 3.2b2 when running locally. I have only tried 3.1 with IIS. I don't believe the problem is in IIS, since this application works using a different servlet container on the same machine.

I have put together a small test case that demonstrates the problem. As you can see from the code below, the servlet is only a few lines long, and it does not even look at the uploaded data. The only thing that is different with each test case is the size of the uploaded file - larger than 40KB fails, but less than 40KB succeeds.

Here is my test servlet - this is the entire code for the whole thing:

// start servlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TestUploadServlet extends HttpServlet {
	
  protected void doPost(HttpServletRequest req,
                      HttpServletResponse res)
                      throws ServletException, IOException {

    ////res.sendRedirect("Error.htm");

    PrintWriter out = res.getWriter();
    out.println("<html><head></head><body>It worked!</body></html>");

    out.flush();
    res.flushBuffer();
  }
}
// end servlet code

If I substitute the "sendRedirect" line for all the lines below that, the same problem occurs.

This is the web page that does the upload:
<html>
<head>
  <title>Test Upload Form</title>
</head>
<body>
   Test Upload Form<br>

   <form name="upload" method="post" enctype="multipart/form-data" 
                 action="../Servlets/testupload">

   <input type="file" name="UploadedFile" accept="*" size="50">

   <input type="submit" name="SubmitBtn" value="Upload File Now">
</form>  
</body>
</html>

Tomcat is still very new to me, so if there is any configuration setting I can change that will resolve this problem, please let me know. I sure hope this can be fixed before 3.2 is final. In its current state I cannot use Tomcat since this web app must be able to accept uploaded files larger than 100 MB (large page full color images or postscript).

If I can supply anything else that will help to nail this one, please let me know.

Steve Fyfe
CNI Corporation
Milford New Hampshire

SFyfe@cnicorp.com
(603) 673-6600


Re: [BUG] Network connection reset while uploading large file

Posted by Arion Yu <ar...@stt.com.hk>.
Hi!

I think you may try opening the input stream of the request object, dump out everything till the end, and then give out response.

Arion

Steve Fyfe wrote:

> I have discovered that when I attempt to upload a file larger than 40KB, Tomcat will just reset the network connection. As a result, IE shows an error screen with the message "Server or DNS not available", and Netscape gives an error message box saying "A network error has occurred while sending data (Connection reset by peer)."
>
>  Whenever I send a file that is smaller than 40KB, the response produced by the test servlet is correctly shown in the browser's window. But if I upload a file larger than 40KB using the exact same configuration and servlet, the code in the servlet is executed but the web page produced by the servlet never appears - the browser's error message appears instead.
>
> This problem occurs both when I run Tomcat locally (Win 98) and when I run it on NT 4 with IIS serving the static pages. I get the same problem using Tomcat 3.1 or 3.2b2 when running locally. I have only tried 3.1 with IIS. I don't believe the problem is in IIS, since this application works using a different servlet container on the same machine.
>
> I have put together a small test case that demonstrates the problem. As you can see from the code below, the servlet is only a few lines long, and it does not even look at the uploaded data. The only thing that is different with each test case is the size of the uploaded file - larger than 40KB fails, but less than 40KB succeeds.
>
> Here is my test servlet - this is the entire code for the whole thing:
>
> // start servlet
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class TestUploadServlet extends HttpServlet {
>
>   protected void doPost(HttpServletRequest req,
>                       HttpServletResponse res)
>                       throws ServletException, IOException {
>
>     ////res.sendRedirect("Error.htm");
>
>     PrintWriter out = res.getWriter();
>     out.println("<html><head></head><body>It worked!</body></html>");
>
>     out.flush();
>     res.flushBuffer();
>   }
> }
> // end servlet code
>
> If I substitute the "sendRedirect" line for all the lines below that, the same problem occurs.
>
> This is the web page that does the upload:
> <html>
> <head>
>   <title>Test Upload Form</title>
> </head>
> <body>
>    Test Upload Form<br>
>
>    <form name="upload" method="post" enctype="multipart/form-data"
>                  action="../Servlets/testupload">
>
>    <input type="file" name="UploadedFile" accept="*" size="50">
>
>    <input type="submit" name="SubmitBtn" value="Upload File Now">
> </form>
> </body>
> </html>
>
> Tomcat is still very new to me, so if there is any configuration setting I can change that will resolve this problem, please let me know. I sure hope this can be fixed before 3.2 is final. In its current state I cannot use Tomcat since this web app must be able to accept uploaded files larger than 100 MB (large page full color images or postscript).
>
> If I can supply anything else that will help to nail this one, please let me know.
>
> Steve Fyfe
> CNI Corporation
> Milford New Hampshire
>
> SFyfe@cnicorp.com
> (603) 673-6600
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

--
[This email and any files transmitted with it are confidential and may contain information that is legally privileged. They are intended solely for the addressee(s). Access to this email by anyone else is unauthorized. If you are not the intended recipient, please delete it and notify the sender by email immediately; you should not copy or use it for any purpose,
nor disclose its contents to any other person. Thank you.]