NetClientOptions reconnect time and attempts not getting triggered.

26 views
Skip to first unread message

murtuza chhil

unread,
Jan 19, 2018, 9:25:06 AM1/19/18
to vert.x
Hello,

For a NetClient I want to reattempt connection attempts on disconnects or when the server is not available.
I added NetClientOptions to trigger those, but I am not seeing any attempt being made. I use a netcat server on commandline.

  NetClientOptions ops = new NetClientOptions();
        ops.setReconnectInterval(TimeUnit.SECONDS.toMillis(5))
           .setReconnectAttempts(100);

        client = vertx.createNetClient(ops);
        connect();

To get around this I now call a timer routine to attempt  a connect after 5 seconds from every place of failure (could not connect, got disconnected). This is working.

        vertx.setTimer(5000, handler -> {
            System.out.println("ReConnect Timer Fired");
            connect();
        });

My question is why are my  NetClientOptions not doing what I think it needs to do?

-chhil

murtuza chhil

unread,
Jan 19, 2018, 10:52:14 AM1/19/18
to vert.x

This probably answers it....

https://groups.google.com/d/msg/vertx/QuJn4ZmUaw0/TMEKiRMjH5AJ

Tim Fox
11/21/14
Ah right. reconnectAttempts is how many attempts to make when connecting to the server, it doesn't mean the client will automatically reconnect itself.

To do that you need to specify closeHandler/exceptionHandler and do the reconnect yourself.
Auto Generated Inline Image 1

Julien Viet

unread,
Jan 19, 2018, 11:50:05 AM1/19/18
to vert.x
Hi,

are you experiencing issues with an established socket that disconnect or on first connect attempt ?

Julien

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/6123a510-662f-4410-8738-b0a5b9fb860d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julien Viet

unread,
Jan 19, 2018, 11:51:30 AM1/19/18
to vert.x
yes you found it.

reconnection is often protocol specific and can likely depends on some state (for instance resending partially data based on ack, etc...)

Julien

On 19 Jan 2018, at 16:52, murtuza chhil <chi...@gmail.com> wrote:


This probably answers it....

https://groups.google.com/d/msg/vertx/QuJn4ZmUaw0/TMEKiRMjH5AJ

Tim Fox
<Auto Generated Inline Image 1.png>
11/21/14
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.

For more options, visit https://groups.google.com/d/optout.
<Auto Generated Inline Image 1.png>

chhil

unread,
Jan 19, 2018, 11:56:27 AM1/19/18
to ve...@googlegroups.com
I am not experiencing that. I am simply putting in the reconnect due to connection drops by remote due to inactivity or maybe the server is still on up.

-chhil 

On Jan 19, 2018 10:20 PM, "Julien Viet" <jul...@julienviet.com> wrote:
Hi,

are you experiencing issues with an established socket that disconnect or on first connect attempt ?

Julien

On 19 Jan 2018, at 15:25, murtuza chhil <chi...@gmail.com> wrote:

Hello,

For a NetClient I want to reattempt connection attempts on disconnects or when the server is not available.
I added NetClientOptions to trigger those, but I am not seeing any attempt being made. I use a netcat server on commandline.

  NetClientOptions ops = new NetClientOptions();
        ops.setReconnectInterval(TimeUnit.SECONDS.toMillis(5))
           .setReconnectAttempts(100);

        client = vertx.createNetClient(ops);
        connect();

To get around this I now call a timer routine to attempt  a connect after 5 seconds from every place of failure (could not connect, got disconnected). This is working.

        vertx.setTimer(5000, handler -> {
            System.out.println("ReConnect Timer Fired");
            connect();
        });

My question is why are my  NetClientOptions not doing what I think it needs to do?

-chhil

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/mkz1eMsKmbo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages