ReadHandler not returning error on client disconnect

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

ReadHandler not returning error on client disconnect

gagansnt
I am using Grizzly NIOInputStream and response suspend/resume facility to read from clients.
Problem I am facing, When a client stops sending file due some error or network problem then I do not get any exception or error message on server side. I am using exactly the same code as mentioned in one of the samples on Grizzly website - Do I need to make any further changes in code in order to know that client has stopped sending data.

in.notifyAvailable(new ReadHandler() {
          @Override
          public void onDataAvailable(){
            try {
              doWrite(this, in, buf, out, parser);
            } catch (IOException e) {
              logger.fatal(e.toString());
            }catch (Exception e) {
              logger.fatal(e.toString());
            }
          }
          @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();
          }
        });


Thanks in advance
Gagan
Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

Ryan Lubke-2
Hi,

Would you mind logging an issue [1] for this?  We'll address it asap.

Thanks,
-rl

[1] http://java.net/jira/browse/GRIZZLY


On 3/30/11 2:04 AM, gagansnt wrote:

> I am using Grizzly NIOInputStream and response suspend/resume facility to
> read from clients.
> Problem I am facing, When a client stops sending file due some error or
> network problem then I do not get any exception or error message on server
> side. I am using exactly the same code as mentioned in one of the samples on
> Grizzly website - Do I need to make any further changes in code in order to
> know that client has stopped sending data.
>
> in.notifyAvailable(new ReadHandler() {
>            @Override
>            public void onDataAvailable(){
>              try {
>                doWrite(this, in, buf, out, parser);
>              } catch (IOException e) {
>                logger.fatal(e.toString());
>              }catch (Exception e) {
>                logger.fatal(e.toString());
>              }
>            }
>            @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();
>            }
>          });
>
>
> Thanks in advance
> Gagan
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/ReadHandler-not-returning-error-on-client-disconnect-tp4271055p4271055.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

oleksiys
Administrator
In reply to this post by gagansnt
Hi Gagan,
agree with Ryan, please file the issue...

One more thing, can you pls. try if you see the same when using Grizzly
2.0.1-SNAPSHOT?

Thanks.

WBR,
Alexey.

On 03/30/2011 02:04 AM, gagansnt wrote:

> I am using Grizzly NIOInputStream and response suspend/resume facility to
> read from clients.
> Problem I am facing, When a client stops sending file due some error or
> network problem then I do not get any exception or error message on server
> side. I am using exactly the same code as mentioned in one of the samples on
> Grizzly website - Do I need to make any further changes in code in order to
> know that client has stopped sending data.
>
> in.notifyAvailable(new ReadHandler() {
>            @Override
>            public void onDataAvailable(){
>              try {
>                doWrite(this, in, buf, out, parser);
>              } catch (IOException e) {
>                logger.fatal(e.toString());
>              }catch (Exception e) {
>                logger.fatal(e.toString());
>              }
>            }
>            @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();
>            }
>          });
>
>
> Thanks in advance
> Gagan
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/ReadHandler-not-returning-error-on-client-disconnect-tp4271055p4271055.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

gagansnt
I checked by using Grizzly 2.0.1-SNAPSHOT and got the same problem.

Gagan
Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

gagansnt
I have logged an issue - http://java.net/jira/browse/GRIZZLY-991 
Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

oleksiys
Administrator
Thanks a lot Gagan!
We will come back to you asap.

WBR,
Alexey.

PS: BTW I'm working on multipart uploader, will have initial impl. ready
soon.


On 03/31/2011 04:25 AM, gagansnt wrote:
> I have logged an issue -  http://java.net/jira/browse/GRIZZLY-991
> http://java.net/jira/browse/GRIZZLY-991
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/ReadHandler-not-returning-error-on-client-disconnect-tp4271055p4273180.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

oleksiys
Administrator
In reply to this post by gagansnt
Hi Gagan,

please check the latest 2.0.1-SNAPSHOT.

Thanks.

WBR,
Alexey.

On 03/31/2011 04:25 AM, gagansnt wrote:
> I have logged an issue -  http://java.net/jira/browse/GRIZZLY-991
> http://java.net/jira/browse/GRIZZLY-991
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/ReadHandler-not-returning-error-on-client-disconnect-tp4271055p4273180.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

gagansnt
Its working now Thanks!  Giving EOFException whenever a client gets disconnected.
I would like to know the change you made in the source code. Would you mind sharing that information.
Reply | Threaded
Open this post in threaded view
|

Re: ReadHandler not returning error on client disconnect

oleksiys
Administrator
Hi Gagan,

sure,

the change might be followed on these diffs [1], [2]. We introduced
method InputBuffer.terminate(), which is getting called when Request
processing terminates for any reason.

WBR,
Alexey.

[1]
http://java.net/projects/grizzly/sources/git/revision/4ecfb85a6ec20628c127c1cc91211a3a9d8ac9b1
[2]
http://java.net/projects/grizzly/sources/git/diff/modules/http-server/src/main/java/org/glassfish/grizzly/http/server/io/InputBuffer.java?rev1=44fd01e4bf2663a1f0a796f60fd1d7cbc94b60ed&rev2=4ecfb85a6ec20628c127c1cc91211a3a9d8ac9b1

On 04/04/2011 10:00 AM, gagansnt wrote:
> Its working now Thanks!  Giving EOFException whenever a client gets
> disconnected.
> I would like to know the change you made in the source code. Would you mind
> sharing that information.
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/ReadHandler-not-returning-error-on-client-disconnect-tp4271055p4279861.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.