grizzly
  1. grizzly
  2. GRIZZLY-991

ReadHandler not returning error on client disconnect

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1
    • Component/s: http
    • Labels:
      None
    • Environment:

      Linux CentOS 5.5

      Description

      I am writing a File server application that will receives the input files from different clients and save them on server. I am using Grizzly NIOInputStream for reading the request. While using response suspend/resume facility of Grizzly http server I found a problem that when a client stops sending a file due some error or network problem then there is no error message on the server side, rather server code never knows that client stopped abruptly. Ideally it should detect it and should throw an exception.

      I am using exactly the same code as mentioned in one of the samples on Grizzly website. But I modified the echo sample to handle a file upload request and save it on server.

      response.suspend();
      in.notifyAvailable(new ReadHandler() {
      @Override
      public void onDataAvailable() throws IOException

      { logger.info(inputFile + " [onDataAvailable] length: " + in.readyData()); doWrite(this, in, buf, out, parser); }

      @Override
      public void onError(Throwable t)

      { logger.info(inputFile + " [onError]" + t.toString()); System.out.println(inputFile + " [onError]" + t.toString()); }

      @Override
      public void onAllDataRead() {
      System.out.println("[onAllDataRead] length: " + in.readyData());
      logger.info("[onAllDataRead] length: " + in.readyData());
      try

      { doWrite(this, in, buf, out, parser); }

      catch (IOException e)

      { logger.fatal(e.toString()); }

      response.resume();
      }
      });

      To reproduce -
      1. Start your webserver.
      2. Connect to a server from client machine
      3. Try to upload a big file on the server.
      4. Once the upload starts then disconnect the client by unplugging LAN or by stopping the browser.
      5. File upload will stop on server but it will never throw any exception, hence server app could never
      know whether file upload is completed or stopped abruptly due to some error.

        Activity

        Hide
        oleksiys added a comment -

        fixed

        Show
        oleksiys added a comment - fixed
        Hide
        Ryan Lubke added a comment -

        Update owner.

        Show
        Ryan Lubke added a comment - Update owner.

          People

          • Assignee:
            oleksiys
            Reporter:
            gagansnt1
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: