Error on writeRequested
"이희승 (Trustin Lee)"
trustin at gmail.com
Mon May 30 09:26:58 EDT 2011
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]<ml-node+6418081-618031201-301197 at n2.nabble.com> 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>>:
>>
>>
>>> 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>
>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>
>> _______________________________________________
>> netty-users mailing list
>> [hidden email]<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:
>>
>> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Error-on-writeRequested-tp6418009p6418081.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-tp6418009p6418985.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee, http://gleamynode.net/
More information about the netty-users
mailing list