Random connect exceptions

Trustin Lee (이희승) trustin at gmail.com
Sat Nov 21 03:29:11 EST 2009


Hello Shay,

Sorry for getting back to you so late, but would you mind if you could
run the attached test application?  I tried to reproduce the problem
with it, but it never hangs but the connection attempts always time
out within about 1 second.

Please modify the variable 'destination' so that the connection
attempt times out in your environment.

Thanks in advance.

— Trustin Lee, http://gleamynode.net/

On Mon, Nov 9, 2009 at 5:54 PM, Shay Banon <kimchy at gmail.com> wrote:
> Yes, other connections do seem to work. Subsequent connections also
> seem to work...  (when I have the timeout enabled). I added a simple
> retry mechanism which seems to make this problem go away (with a limit
> of 10 times), though it works around the problem, not solve it.
>
> On Mon, Nov 9, 2009 at 9:22 AM, Christian Migowski <chrismfwrd at gmail.com> wrote:
>> Hi Shay,
>>
>> when a connection attempt hangs, can you connect to the server with
>> another instance of your application?
>> Before you changed the code to wait until finished, were subsequent
>> connection attempts (after a failed one) successful?
>>
>>
>> christian!
>>
>>
>>
>> On Sun, Nov 8, 2009 at 11:22 AM, Shay Banon <kimchy at gmail.com> wrote:
>>> Here is the client bootstrap initialization:
>>>
>>>        clientBootstrap = new ClientBootstrap(new
>>> NioClientSocketChannelFactory(new VirtualExecutorService(threadPool),
>>> new VirtualExecutorService(threadPool)));
>>>
>>>        ChannelPipelineFactory clientPipelineFactory = new
>>> ChannelPipelineFactory() {
>>>            @Override public ChannelPipeline getPipeline() throws Exception {
>>>                ChannelPipeline pipeline = Channels.pipeline();
>>>                pipeline.addLast("decoder", new SizeHeaderFrameDecoder());
>>>                pipeline.addLast("dispatcher", new
>>> MessageChannelHandler(NettyTransport.this));
>>>                return pipeline;
>>>            }
>>>        };
>>>
>>>        clientBootstrap.setPipelineFactory(clientPipelineFactory);
>>>
>>>        clientBootstrap.setOption("connectTimeoutMillis",
>>> connectTimeout.millis());
>>>
>>> And here is the connect operation:
>>>
>>>                ChannelFuture channelFuture = clientBootstrap.connect(address);
>>>                channelFuture.awaitUninterruptibly();
>>>                if (!channelFuture.isSuccess()) {
>>>                       // throw connect excep
>>>                }
>>>                return channelFuture.getChannel();
>>>
>>> The server is a netty server bound to 0.0.0.0, and the address it to
>>> connect to is the local ip address (as derived by java, for example,
>>> 192.168....).
>>>
>>> Shay
>>>
>>>
>>> On Sun, Nov 8, 2009 at 11:22 AM, Trustin Lee (이희승) <trustin at gmail.com> wrote:
>>>> Perhaps it might be a bug.  I will investigate a little bit more.
>>>> Could you paste the whole bootstrap initialization and connection
>>>> attempt code?
>>>>
>>>> Thanks
>>>>
>>>> — Trustin Lee, http://gleamynode.net/
>>>>
>>>>
>>>>
>>>> On Sun, Nov 8, 2009 at 5:38 PM, Shay Banon <kimchy at gmail.com> wrote:
>>>>> I see. Now, when I try with waiting without any timeout value
>>>>> (channelFuture.awaitUninterruptibly()), then it simply hangs without
>>>>> returning. I do set the connectionTimeoutMillis... :
>>>>>
>>>>> clientBootstrap.setOption("connectTimeoutMillis", connectTimeout.millis());
>>>>>
>>>>> and it is set to 1 second.
>>>>>
>>>>> Cheers,
>>>>> Shay
>>>>>
>>>>> On Sat, Nov 7, 2009 at 5:09 PM, Trustin Lee (이희승) <trustin at gmail.com> wrote:
>>>>>> If you have specified connectTimeoutMillis option correctly, you
>>>>>> should not specify the timeout value when you call
>>>>>> ChannelFuture.await().  ChannelFuture will complete automatically on
>>>>>> connection timeout.
>>>>>>
>>>>>> You cannot assume that the connection attempt has failed if
>>>>>> ChannelFuture.isSuccess() returned false because it might also mean
>>>>>> that the connection attempt is still in progress.  To make sure that
>>>>>> the connection attempt is finished, you have to await the future until
>>>>>> its completion.  If ChannelFuture is complete, ChannelFuture.isDone()
>>>>>> returns true.
>>>>>>
>>>>>> HTH
>>>>>>
>>>>>> — Trustin Lee, http://gleamynode.net/
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Nov 3, 2009 at 11:49 PM, Shay Banon <kimchy at gmail.com> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>>  First of all, thanks for the reply. I have added the connectTimeout
>>>>>>> option as you suggested, and it does not seem to help. Even when I set
>>>>>>> it to a higher value, it simply waits there until the timeout passed,
>>>>>>> and then the channelFuture#isSuccess is false. I still don't get the
>>>>>>> actual cause as well. I am using netty version 3.1.5.
>>>>>>>
>>>>>>>  What is the scenario that the cause of the future is null?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Shay
>>>>>>>
>>>>>>> On Tue, Nov 3, 2009 at 1:41 PM, Christian Migowski <chrismfwrd at gmail.com> wrote:
>>>>>>>> Hi Shay,
>>>>>>>>
>>>>>>>> the code looks OK, but two things:
>>>>>>>>
>>>>>>>> 1) did you set the connectTimeout to the bootstrap, i.e.
>>>>>>>>
>>>>>>>>  clientBootstrap.setOption("connectTimeoutMillis",connectTimeout.millis());
>>>>>>>>
>>>>>>>> if no that might be the reason: the connection attempt is just not finished yet
>>>>>>>>
>>>>>>>> 2) if yes do you use the latest Netty version? The NIO transport in
>>>>>>>> versions prior to 3.1.4 (if i remember correctly) did not respect the
>>>>>>>> connect timeout.
>>>>>>>>
>>>>>>>> hth,
>>>>>>>> regards,
>>>>>>>> christian!
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Nov 3, 2009 at 12:19 PM, Shay Banon <kimchy at gmail.com> wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>>  I am getting random connect failures when using netty, which I am
>>>>>>>>> trying to track down the cause of it. First, here is the code I use to
>>>>>>>>> connect:
>>>>>>>>>
>>>>>>>>>            InetSocketAddress address = // obtain the address to connect to
>>>>>>>>>            ChannelFuture channelFuture = clientBootstrap.connect(address);
>>>>>>>>>            channelFuture.awaitUninterruptibly(connectTimeout.millis());
>>>>>>>>> // connect timeout is 1 second
>>>>>>>>>            if (!channelFuture.isSuccess()) {
>>>>>>>>>                throw new ConnectTransportException(address, "",
>>>>>>>>> channelFuture.getCause());
>>>>>>>>>            }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> First, is this code fragment correct, or am I missing something?
>>>>>>>>> Second, the strange thing I get is that the channelFuture.getCause()
>>>>>>>>> is null .., so I don't really know the underlying problem here.
>>>>>>>>>
>>>>>>>>> Any idea?
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Shay
>>>>>>>>> _______________________________________________
>>>>>>>>> netty-users mailing list
>>>>>>>>> netty-users at lists.jboss.org
>>>>>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> netty-users mailing list
>>>>>>>> netty-users at lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> netty-users mailing list
>>>>>>> netty-users at lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> netty-users mailing list
>>>>>> netty-users at lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> netty-users mailing list
>>>>> netty-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>>
>>>>
>>>> _______________________________________________
>>>> netty-users mailing list
>>>> netty-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>>
>>>
>>> _______________________________________________
>>> netty-users mailing list
>>> netty-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/netty-users
>>>
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ShortConnectTimeoutTest.java
Type: application/octet-stream
Size: 1869 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20091121/64a9c80a/attachment.obj 


More information about the netty-users mailing list