Netty and requestTimeout

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

Netty and requestTimeout

fbarbat
Hi,

I'm having problems with requestTimeout on a Netty component. A NullPointerException raises when camel tries to get UnitOfWork. It looks like the timeout is raising even though there is no current inflight exchange. Any ideas? Thanks.

An exception was thrown by a user handler while handling an exception event ([id: 0x0763787d, /10.172.10.125:39622 :> /192.168.1.1:4004] EXCEPTION: org.jboss.netty.handler.timeout.ReadTimeoutException)
java.lang.NullPointerException
        at org.apache.camel.processor.RedeliveryErrorHandler.processAsyncErrorHandler(RedeliveryErrorHandler.java:486)
        at org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:409)
        at org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:321)
        at org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:127)
        at org.apache.camel.component.netty.NettyProducer$NettyProducerCallback.done(NettyProducer.java:461)
        at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:90)
        at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:536)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:236)
        at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask$1.run(ReadTimeoutHandler.java:276)
        at org.jboss.netty.channel.socket.ChannelRunnableWrapper.run(ChannelRunnableWrapper.java:40)
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:366)
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:290)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:90)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        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)
Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

fbarbat
I forgot to mention I'm using persistent connections with this producer.
Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

Claus Ibsen-2
In reply to this post by fbarbat
Hi

What version of Camel do you use? And can you show us the netty uri
you use that causes the reques timeout?

On Sat, Aug 31, 2013 at 1:00 AM, fbarbat <[hidden email]> wrote:

> Hi,
>
> I'm having problems with requestTimeout on a Netty component. A
> NullPointerException raises when camel tries to get UnitOfWork. It looks
> like the timeout is raising even though there is no current inflight
> exchange. Any ideas? Thanks.
>
> An exception was thrown by a user handler while handling an exception event
> ([id: 0x0763787d, /10.172.10.125:39622 :> /192.168.1.1:4004] EXCEPTION:
> org.jboss.netty.handler.timeout.ReadTimeoutException)
> java.lang.NullPointerException
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.processAsyncErrorHandler(RedeliveryErrorHandler.java:486)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:409)
>         at org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:321)
>         at
> org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:127)
>         at
> org.apache.camel.component.netty.NettyProducer$NettyProducerCallback.done(NettyProducer.java:461)
>         at
> org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:90)
>         at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:536)
>         at
> org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:236)
>         at
> org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask$1.run(ReadTimeoutHandler.java:276)
>         at
> org.jboss.netty.channel.socket.ChannelRunnableWrapper.run(ChannelRunnableWrapper.java:40)
>         at
> org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:366)
>         at
> org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:290)
>         at
> org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:90)
>         at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
>         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)
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Netty-and-requestTimeout-tp5738341.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

fbarbat
Hi,

This test reproduces the exception. The System.in.read() at the end is just to wait for the exception to appear. Any ideas?

Thanks.

package camel.test;

import java.io.IOException;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Assert;
import org.junit.Test;

public class CamelNettyTest extends CamelTestSupport {

        @Override
        protected RouteBuilder createRouteBuilder() throws Exception {
                return new RouteBuilder() {

                        @Override
                        public void configure() throws Exception {
                                from("direct:out").to(
                                                "netty:tcp://localhost:8080?requestTimeout=5000");

                                from("netty:tcp://localhost:8080")
                                                .to("log:nettyCase?showAll=true&multiline=true");
                                ;

                        }
                };
        }

        @Test
        public void test() throws IOException {
                String result = template.requestBody("direct:out", "hello",
                                String.class);
                Assert.assertEquals("hello", result);
                System.in.read();
        }
}

Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

fbarbat
Sorry, I forgot to mention I'm using 2.11.1
Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

fbarbat
As a workaround, I implemented a handler which modifies the pipeline on every request so the ReadTimeoutHandler is removed once the response is read. Specifically, a CamelRequestTimeoutHandler is inserted before Camel's ClientChannelHandler. My handler inserts a ReadTimeoutHandler on write and removes it on read.
This has no problems with Camel use of Netty because of the pool of channels. If the access to a single channel had been concurrent, this workaround wouldn't have worked. I can send you a patch if you are interested.

Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

Claus Ibsen-2
Hi

Yeah removing the timeout handler is a good idea. And we love
contributions, so feel free to log a JIRA and attach a patch.
http://camel.apache.org/contributing.html

On Mon, Sep 2, 2013 at 10:05 PM, fbarbat <[hidden email]> wrote:

> As a workaround, I implemented a handler which modifies the pipeline on every
> request so the ReadTimeoutHandler is removed once the response is read.
> Specifically, a CamelRequestTimeoutHandler is inserted before Camel's
> ClientChannelHandler. My handler inserts a ReadTimeoutHandler on write and
> removes it on read.
> This has no problems with Camel use of Netty because of the pool of
> channels. If the access to a single channel had been concurrent, this
> workaround wouldn't have worked. I can send you a patch if you are
> interested.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Netty-and-requestTimeout-tp5738341p5738536.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: Netty and requestTimeout

Claus Ibsen-2
Hi

Logged a ticket to fix this
https://issues.apache.org/jira/browse/CAMEL-6730

On Tue, Sep 3, 2013 at 9:22 AM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Yeah removing the timeout handler is a good idea. And we love
> contributions, so feel free to log a JIRA and attach a patch.
> http://camel.apache.org/contributing.html
>
> On Mon, Sep 2, 2013 at 10:05 PM, fbarbat <[hidden email]> wrote:
>> As a workaround, I implemented a handler which modifies the pipeline on every
>> request so the ReadTimeoutHandler is removed once the response is read.
>> Specifically, a CamelRequestTimeoutHandler is inserted before Camel's
>> ClientChannelHandler. My handler inserts a ReadTimeoutHandler on write and
>> removes it on read.
>> This has no problems with Camel use of Netty because of the pool of
>> channels. If the access to a single channel had been concurrent, this
>> workaround wouldn't have worked. I can send you a patch if you are
>> interested.
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Netty-and-requestTimeout-tp5738341p5738536.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen