Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4062635

Bug when shutting down java.net.Socket (and/or in Java Web Server)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.1.5
    • 1.1.1
    • core-libs
    • None
    • 1.1.5
    • x86
    • windows_nt
    • Not verified



      Name: sg39081 Date: 07/01/97


      1) STEPS TO REPRODUCE THE PROBLEM:

      Submit a large form to the Java Web Server:

      Richard Evans wrote:
      >I have JWS beta running on NT Workstation 4.0, but I have a problem when
      >submitting POST requests from forms with a lot of data. When the form
      >contains many fields or a lot of data, I always get the error:
      >
      > A network error occurred while Netscape
      > was receiving data.
      > (Network Error: Connection reset by peer)
      >
      >I get a similar message from MSIE.
      >
      >I don't seem to have any problems if the server is running on Solaris. I
      >haven't tried Windows 95. I get the error from browsers running on the same
      >machine as the server and also acrosss the network from Solaris. I _think_
      >that the same problwm occurs with JeevesA2 but I am not 100% sure.
      >
      >The error occurs if I post to a custom servlet which handles the form fields
      >and also to the simpleservlet example.



      2) JAVA SOURCE CODE THAT DEMONSTRATES THE PROBLEM:

      None! HTML Code only:

      Richard Evans wrote:
      >I made an html file which demonstrates the problem. It is simply a form with
      >a text box with a lot of text in it.
      >
      >---- HTML file bigform.htm
      ><html>
      >
      ><head>
      ><title>Big form</title>
      ></head>
      >
      ><body bgcolor="#FFFFFF">
      >
      ><form action="/servlet/simpleservlet" method="POST">
      > <p><textarea name="S1" rows="15" cols="50">This text box demonstrates a possible
      >bug in the Win32 version of the Java
      >Web Server Beta release.
      >
      >When there is more than a certain amount
      >of text in this box, and the form is
      >submitted using Netscape 3 or MSIE 3,
      >you get a connection reset by peer error
      >message.
      >
      >The error also happens if you have a lot
      >of form items each with a small amount
      >of text. It seems to be the total size
      >of the request which matters.
      >
      >The error happens even if you submit the
      >request to the SimpleServlet example
      >servlet.
      >
      >You do not seem to get this problem if
      >the server is running on Solaris.
      ></textarea><br>
      > <input type="submit" name="B1" value="Submit"></p>
      ></form>
      ></body>
      ></html>
      >---- end of bigform.html


      3) EXACT TEXT OF ERROR MESSAGE

      > A network error occurred while Netscape
      > was receiving data.
      > (Network Error: Connection reset by peer)


      4) TRACE INFORMATION

      None.


      5) ADDITIONAL RELEVANT INFORMATION

      Please read the following e-mail exchange between myself (David Rosenstrauch, ###@###.###) and Richard Evans (###@###.###).

      Although we do not know of any way to demonstrate the problem other than via the Java Web Server, Richard has researched this problem extensively and believes that this problem is being caused by a bug in java.net.Socket, NOT a problem with the Java Web Server!




      ==========
      Message #1
      ==========

      Hi. I've been experiencing a problem with JWS whereby forms that contain a large amount of data cause errors.

      I decided to look through my list mailbox to see if anyone else was having this problem, and found that someone was. The messsage below describes the exact problem.

      However, I never saw a fix/solution/workaround message posted. Is there one?

      Please respond via e-mail, as I am no longer a member of the list.


      Thanks!

      Dave Rosenstrauch
      Advanced Web Technologies Corp.
      www.javatrain.com



      ==========
      Message #2
      ==========

      At 04:12 PM 4/25/97 +0100, Richard Evans wrote:
      >Well, various posts from the JWS team have mentioned a bug they will fix for
      >the next release.
      >
      >But I believe the bug is in the Win32 network code in the JDK. I acquired the
      >JDK source (it is freely available for internal use only), build it on NT, and
      >did some experiments. I found a problem in the socket close routine in the
      >Win32 native code; changing a '2' to a '1' in one place fixed the problem! It
      >may not have been a bug but the change certainly works.
      >
      >If you get the code I can tell you what do so; I suspect I am prevented by the
      >source license terms from sending you the fixed DLL.

      ...

      >Richard
      >-------------------------------------------------------------------------------
      >Richard Evans Telephone : (+44) 1223 428200
      >Tadpole Technology plc Fax : (+44) 1223 428203
      >Cambridge Science Park
      >Milton Road E-Mail : ###@###.###
      >Cambridge, CB4 4WQ, UK
      >------------------------------------------------------------------------------



      ==========
      Message #3
      ==========

      At 04:49 PM 4/25/97 +0100, you wrote:
      > > X-Sender: ###@###.###
      > > X-Mailer: Windows Eudora Pro Version 3.0 (32)
      > > Date: Fri, 25 Apr 1997 11:31:58 -0400
      > > From: David Rosenstrauch <###@###.###>
      > > Mime-Version: 1.0
      > >
      > > Richard,
      > >
      > > Thanks for the speedy response!
      > >
      > >
      > >
      > > Ick! Doesn't sound like a happy solution to me. I would prefer not to
      > > have to

      [mess]

      > > around with the native code.
      > >
      > > Hmmmm .... I'll have to think about what to do about this.
      > >
      > > Please let me know if you hear anything else. This bug is a bit of a
      > > show-stopper for me.
      > >
      > > Thanks again,
      > >
      > > Dave
      >
      >
      >Well ... here are some thoughts and theories ...
      >
      >The connection is reset when the Win32 socket function 'shutdown(socket, 2)'
      >is called in the socket close routine in the Win32 native net code.
      >
      >The 2 argument means "block subsequent sends and receives". Now, the Win32
      >API spec for shutdown says "For TCP sockets, if there is still data queued on
      >the socket waiting to be received, or data arrives subsequently, the
      >connection is reset ...". I changed to 2 to 1 and block just sends and I
      >didn't have the reset problem.
      >
      >I have two suggested fixes:
      >
      >1. Change the form to use GET rather than POST - the servlet APIs handle the
      >two methods transparently and you shouldn't have to change any code. You may
      >think that sending a huge amount of data via a GET is strange, but I have
      >tried it with my test form and it does work.
      >
      >2. If my theory about shutdown and the reset is correct, it may help if, after
      >getting the parameters, you do req.getInputStream() and read from this stream
      >until eof or exception. This _may_ consume the pending data which is what
      >_could_ be causing the reset. Remember to get the input stream _after_
      >getting the parameters since the servlet framework also reads from the stream
      >to get the POST data. I haven't tried this suggestion.
      >
      >Let me know how you get on.
      >
      >Richard


      ======================================================================

            brenaudsunw Benjamin Renaud (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: