Error on writeRequested

jsia24 jsia18 at gmail.com
Mon May 30 10:52:14 EDT 2011


Even if I close the connection e.getChannel.close() it still triggers the
idlehandler, is there a way of removing it from the monitoring of the
idlesocket monitor?

On Mon, May 30, 2011 at 10:49 PM, Jason Sia <jsia18 at gmail.com> wrote:

> Do you think it's a good idea if I store the channelId in a list and check
> it in the list if it already timed out but my problem is how do I clear this
> list if it is already storing a lot of channel ids
>
> On Mon, May 30, 2011 at 10:44 PM, Trustin Lee [via Netty Forums and Mailing
> Lists] <ml-node+6419401-1091358087-301197 at n2.nabble.com> wrote:
>
>> I see.  So, you are not closing the connection since the first
>> channelIdle event.  In spite that channelIdle event is triggered
>> repetitively, there's no way to distinguish the second event from the
>> first one currently.  I think that is the missing feature.  To work
>> around this problem, you need to maintain a state variable that counts
>> the number of consecutive channelIdle events and write the response only
>> when the counter is 0 (i.e. first channelIdle event).
>>
>> HTH
>>
>> On 05/30/2011 11:35 PM, Jason Sia wrote:
>>
>> > When I tried to write a response to the idle channel it writes the first
>>
>> > time then the idletimer continues to run and it still detect that the
>> > channel is idle even though I wrote a response on it.  What do I need to
>>
>> > do for it to change its state,  I think the error is in there that's why
>>
>> > it is saying that I cannot send more response than the request
>> >
>> > On Mon, May 30, 2011 at 9:50 PM, jsia24 <[hidden email]<http://user/SendEmail.jtp?type=node&node=6419401&i=0>
>> > <mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=6419401&i=1>>>
>> wrote:
>> >
>> >     when I add e.getChannel().close()
>> >
>> >     java.nio.channels.ClosedChannelException
>> >             at
>> >
>> sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:133)
>> >             at
>> >     sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:324)
>> >             at
>> >
>> org.jboss.netty.channel.socket.nio.SocketSendBufferPool$PooledSendBuffer.transferTo(SocketSendBufferPool.java:239)
>>
>> >             at
>> >
>> org.jboss.netty.channel.socket.nio.NioWorker.write0(NioWorker.java:469)
>> >             at
>> >
>> org.jboss.netty.channel.socket.nio.NioWorker.writeFromTaskLoop(NioWorker.java:392)
>>
>> >             at
>> >
>> org.jboss.netty.channel.socket.nio.NioSocketChannel$WriteTask.run(NioSocketChannel.java:276)
>>
>> >             at
>> >
>> org.jboss.netty.channel.socket.nio.NioWorker.processWriteTaskQueue(NioWorker.java:268)
>>
>> >             at
>> >     org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:199)
>>
>> >             at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>
>> >             at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>
>> >             at java.lang.Thread.run(Thread.java:662)
>> >
>> >     it complains that it is writing to an open socket do I need to kill
>> the
>> >     idletimer before closing the connection? if yes, how is it done? I
>> >     wanted to
>> >     use persistent connection, am I still doing it right if I close the
>> >     connection?
>> >
>> >     On Mon, May 30, 2011 at 9:48 PM, Norman Maurer-2 [via Netty Forums
>> and
>> >     Mailing Lists] <[hidden email]<http://user/SendEmail.jtp?type=node&node=6419401&i=2>
>> >     <mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=6419401&i=3>>>
>> wrote:
>> >
>> >      > Nope it will not close the connection. It will add a listener
>> which
>> >      > will get fired on a event. If you want to close a connection you
>> >      > should use e.getChannel().close();
>> >      >
>> >      > Bye,
>> >      > Norman
>> >      >
>> >      >
>> >      > 2011/5/30 jsia24 <[hidden
>> >     email]<http://user/SendEmail.jtp?type=node&node=6419199&i=0
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=0>>>:
>> >      >
>> >      >
>> >      > > When I try to do this
>> >      > >
>> >      > > ChannelFuture future = e.getChannel().write(response);
>> >      > > future.addListener(ChannelFutureListener.CLOSE);
>> >      > >
>> >      > > it closes the connection right? It's an IdleStateListener, when
>>
>> >     i gets
>> >      > idle
>> >      > > i write a response then will the code above close that
>> connection?
>> >      > >
>> >      > >
>> >      > > On Mon, May 30, 2011 at 9:37 PM, Trustin Lee [via Netty Forums
>> and
>> >      > Mailing
>> >      > > Lists] <[hidden
>> >     email]<http://user/SendEmail.jtp?type=node&node=6419199&i=1
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=1>>>
>> >      > wrote:
>> >      > >
>> >      > >> Are you sure that you are not writing more responses than the
>> >     number of
>> >      > >> received requests?  For example, sending more than one
>> >     response for a
>> >      > >> single request is not right.
>> >      > >>
>> >      > >> On 05/30/2011 10:31 PM, jsia24 wrote:
>> >      > >>
>> >      > >> > I'm writing a comet server.
>> >      > >> >
>> >      > >> > On Mon, May 30, 2011 at 9:29 PM, Trustin Lee [via Netty
>> >     Forums and
>> >      > >> Mailing
>> >      > >> > Lists]<[hidden email]<
>> >      > http://user/SendEmail.jtp?type=node&node=6419159&i=0
>> >     <http://user/SendEmail.jtp?type=node&node=6419159&i=0>>>
>> >      > >>  wrote:
>> >      > >> >
>> >      > >> >> Are you writing a server, or a client?
>> >      > >> >>
>> >      > >> >> On 05/30/2011 09:55 PM, jsia24 wrote:
>> >      > >> >>
>> >      > >> >>> Here it is:
>> >      > >> >>>       I am actually saving the MessageEvents in a HashMap
>> >     and reply
>> >      > to
>> >      > >> >> them
>> >      > >> >>> when there is an event so what I did is to send a default
>> >     message
>> >      > when
>> >      > >> it
>> >      > >> >>
>> >      > >> >>> did not receive an event for a period of time,  it does
>> >     not produce
>> >      > an
>> >      > >> >> error
>> >      > >> >>> if I do not write any response to the IdleStateEvent e (
>> >     if I just
>> >      > do
>> >      > >> >>> e.getChannel.close() )
>> >      > >> >>>
>> >      > >> >>> java.lang.IllegalStateException: cannot send more
>> >     responses than
>> >      > >> requests
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.handler.codec.http.HttpContentEncoder.writeRequested(HttpContentEncoder.java:102)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > org.jboss.netty.channel.Channels.write(Channels.java:611)
>> >      > >> >>>           at
>> >      > org.jboss.netty.channel.Channels.write(Channels.java:578)
>> >      > >> >>>           at
>> >      > >> >>>
>> >      >
>> >
>> org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:259)
>> >      > >>
>> >      > >> >>>           at
>> >      > >> >>
>> org.comet.classes.IdleHandler.channelIdle(IdleHandler.java:31)
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler.handleUpstream(IdleStateAwareChannelHandler.java:46)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.handler.timeout.IdleStateHandler.channelIdle(IdleStateHandler.java:324)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.handler.timeout.IdleStateHandler$WriterIdleTimeoutTask.run(IdleStateHandler.java:382)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:519)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:440)
>>
>> >      >
>> >      > >>
>> >      > >> >>
>> >      > >> >>>           at
>> >      > >> >>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:379)
>> >      > >> >>>           at java.lang.Thread.run(Thread.java:662)
>> >      > >> >>>
>> >      > >> >>> public class IdleHandler extends
>> >     IdleStateAwareChannelHandler {
>> >      > >> >>>        public void channelIdle(ChannelHandlerContext ctx,
>> >      > >> IdleStateEvent
>> >      > >> >> e) {
>> >      > >> >>>            HttpResponse response = new
>> >     DefaultHttpResponse(HTTP_1_1,
>> >      >
>> >      > >> OK);
>> >      > >> >>>
>> >       response.setContent(ChannelBuffers.copiedBuffer("{}",
>> >      > >> >>> CharsetUtil.UTF_8));
>> >      > >> >>>            response.setHeader(CONTENT_TYPE, "text/plain;
>> >      > >> charset=UTF-8");
>> >      > >> >>>            response.setHeader(CONTENT_LENGTH,
>> >      > >> >>> response.getContent().readableBytes());
>> >      > >> >>>
>> >       response.setHeader("Access-Control-Allow-Origin", "*");
>> >      > >> >>>            ChannelFuture future =
>> >     e.getChannel().write(response);
>> >      > >> >>>
>>  future.addListener(ChannelFutureListener.CLOSE);
>> >      > >> >>>        }
>> >      > >> >>> }
>> >      > >> >>>
>> >      > >> >>> On Mon, May 30, 2011 at 3:16 PM, Norman Maurer-2 [via
>> >     Netty Forums
>> >      > and
>> >      > >> >>> Mailing Lists]<[hidden email]<
>> >      > >> http://user/SendEmail.jtp?type=node&node=6419124&i=0
>> >     <http://user/SendEmail.jtp?type=node&node=6419124&i=0>>>
>> >      > >> >>   wrote:
>> >      > >> >>>
>> >      > >> >>>> Can you post the stacktrace and your code?
>> >      > >> >>>>
>> >      > >> >>>> Thanks
>> >      > >> >>>> Norman
>> >      > >> >>>>
>> >      > >> >>>> 2011/5/30, jsia24<[hidden email]<
>> >      > >> >> http://user/SendEmail.jtp?type=node&node=6418081&i=0
>> >     <http://user/SendEmail.jtp?type=node&node=6418081&i=0>>>:
>> >      > >> >>>>
>> >      > >> >>>>
>> >      > >> >>>>> Hi ,
>> >      > >> >>>>>
>> >      > >> >>>>>       When I try to send a response on the IdleHandler,
>> >     it is
>> >      > >> producing
>> >      > >> >> an
>> >      > >> >>>>> error:  cannot send more responses than requests. Could
>> >     anyone
>> >      > help
>> >      > >> on
>> >      > >> >>>> how
>> >      > >> >>>>> to resolve this?
>> >      > >> >>>>>
>> >      > >> >>>>> --
>> >      > >> >>>>> View this message in context:
>> >      > >> >>>>>
>> >      > >> >>>>
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6418009.html
>> >      > >> >>>>> Sent from the Netty User Group mailing list archive at
>> >     Nabble.com.
>> >      >
>> >      > >> >>>>> _______________________________________________
>> >      > >> >>>>> netty-users mailing list
>> >      > >> >>>>> [hidden email]<
>> >      > http://user/SendEmail.jtp?type=node&node=6418081&i=1
>> >     <http://user/SendEmail.jtp?type=node&node=6418081&i=1>>
>> >      > >>
>> >      > >> >>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >> >>>>>
>> >      > >> >>>> _______________________________________________
>> >      > >> >>>> netty-users mailing list
>> >      > >> >>>> [hidden email]<
>> >      > http://user/SendEmail.jtp?type=node&node=6418081&i=2
>> >     <http://user/SendEmail.jtp?type=node&node=6418081&i=2>>
>> >      > >> >>>> https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >> >>>>
>> >      > >> >>>>
>> >      > >> >>>> ------------------------------
>> >      > >> >>>>    If you reply to this email, your message will be added
>>
>> >     to the
>> >      > >> >> discussion
>> >      > >> >>>> below:
>> >      > >> >>>>
>> >      > >> >>>>
>> >      > >> >>
>> >      > >> >>>>
>> >      > >> >>>>
>> >      > >> >>>
>> >      > >> >>>
>> >      > >> >>> --
>> >      > >> >>> View this message in context:
>> >      > >> >>
>> >      > >>
>> >      >
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6418985.html
>> >      > >> >>
>> >      > >> >>> Sent from the Netty User Group mailing list archive at
>> >     Nabble.com.
>> >      > >> >>> _______________________________________________
>> >      > >> >>> netty-users mailing list
>> >      > >> >>> [hidden
>> >     email]<http://user/SendEmail.jtp?type=node&node=6419124&i=1
>> >     <http://user/SendEmail.jtp?type=node&node=6419124&i=1>>
>> >      >
>> >      > >> >>> https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >> >>
>> >      > >> >>
>> >      > >> >> --
>> >      > >> >> Trustin Lee, http://gleamynode.net/
>> >      > >> >> _______________________________________________
>> >      > >> >> netty-users mailing list
>> >      > >> >> [hidden
>> >     email]<http://user/SendEmail.jtp?type=node&node=6419124&i=2
>> >     <http://user/SendEmail.jtp?type=node&node=6419124&i=2>>
>> >      >
>> >      > >> >> https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >> >> what we call human nature in actuality is human habit
>> >      > >> >> http://gleamynode.net/
>> >      > >> >>
>> >      > >> >>
>> >      > >> >> ------------------------------
>> >      > >> >>   If you reply to this email, your message will be added to
>> the
>> >      > >> discussion
>> >      > >> >> below:
>> >      > >> >>
>> >      > >> >>
>> >      > >>
>> >      > >> >>
>> >      > >> >>
>> >      > >> >
>> >      > >> >
>> >      > >> > --
>> >      > >> > View this message in context:
>> >      > >>
>> >      >
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419138.html
>> >      > >>
>> >      > >> > Sent from the Netty User Group mailing list archive at
>> >     Nabble.com.
>> >      > >> > _______________________________________________
>> >      > >> > netty-users mailing list
>> >      > >> > [hidden email]
>> >     <http://user/SendEmail.jtp?type=node&node=6419159&i=1
>> >     <http://user/SendEmail.jtp?type=node&node=6419159&i=1>>
>> >      >
>> >      > >> > https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >>
>> >      > >>
>> >      > >> --
>> >      > >> Trustin Lee, http://gleamynode.net/
>> >      > >> _______________________________________________
>> >      > >> netty-users mailing list
>> >      > >> [hidden email]
>> >     <http://user/SendEmail.jtp?type=node&node=6419159&i=2
>> >     <http://user/SendEmail.jtp?type=node&node=6419159&i=2>>
>> >      > >> https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >> what we call human nature in actuality is human habit
>> >      > >> http://gleamynode.net/
>> >      > >>
>> >      > >>
>> >      > >> ------------------------------
>> >      > >>  If you reply to this email, your message will be added to the
>>
>> >      > discussion
>> >      > >> below:
>> >      > >>
>> >      > >>
>> >      >
>> >      > >>
>> >      > >>
>> >      > >
>> >      > >
>> >      > > --
>> >      > > View this message in context:
>> >      >
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419169.html
>> >      >
>> >      > > Sent from the Netty User Group mailing list archive at
>> Nabble.com.
>> >      > > _______________________________________________
>> >      > > netty-users mailing list
>> >      > > [hidden email]
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=2
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=2>>
>> >      > > https://lists.jboss.org/mailman/listinfo/netty-users
>> >      > >
>> >      >
>> >      > _______________________________________________
>> >      > netty-users mailing list
>> >      > [hidden email]
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=3
>> >     <http://user/SendEmail.jtp?type=node&node=6419199&i=3>>
>> >      > https://lists.jboss.org/mailman/listinfo/netty-users
>> >      >
>> >      >
>> >      > ------------------------------
>> >      >  If you reply to this email, your message will be added to the
>> >     discussion
>> >      > below:
>> >      >
>> >      >
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419199.html
>> >      >  To unsubscribe from Error on writeRequested, click
>> >     here<
>>     <
>>
>> >      >
>> >      >
>> >
>> >
>> >     --
>> >     View this message in context:
>> >
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419211.html
>> >     Sent from the Netty User Group mailing list archive at Nabble.com.
>> >     _______________________________________________
>> >     netty-users mailing list
>> >     [hidden email]<http://user/SendEmail.jtp?type=node&node=6419401&i=4><mailto:[hidden
>> email] <http://user/SendEmail.jtp?type=node&node=6419401&i=5>>
>> >     https://lists.jboss.org/mailman/listinfo/netty-users
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > netty-users mailing list
>> > [hidden email] <http://user/SendEmail.jtp?type=node&node=6419401&i=6>
>> > https://lists.jboss.org/mailman/listinfo/netty-users
>>
>>
>> --
>> Trustin Lee, http://gleamynode.net/
>> _______________________________________________
>> netty-users mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=6419401&i=7>
>> https://lists.jboss.org/mailman/listinfo/netty-users
>> what we call human nature in actuality is human habit
>> http://gleamynode.net/
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419401.html
>>  To unsubscribe from Error on writeRequested, click here<http://netty-forums-and-mailing-lists.685743.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=6418009&code=anNpYTE4QGdtYWlsLmNvbXw2NDE4MDA5fDE0MTk5NTMxMjM=>.
>>
>>
>
>


--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6419433.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list