Timed out waiting for a reply

1,217 views
Skip to first unread message

Евгений Мартын

unread,
Sep 15, 2016, 11:46:16 AM9/15/16
to vert.x
Hi,

I try write cluster vertx in Java.

Config for deploy verticle:

        Config hazelcastConfig = new Config();
       
       
//----------
       
       
NetworkConfig network = hazelcastConfig.getNetworkConfig();
        network
.setPort(40000);
       
//network.setPortAutoIncrement(false);
       
JoinConfig join = network.getJoin();
               
        join
.getMulticastConfig().setEnabled(false);
        join
.getTcpIpConfig()
           
.addMember("10.130.58.254")
           
.setRequiredMember("10.130.58.16")
           
.setEnabled(true);
       
       
//----------
       
       
ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
       
       
VertxOptions options = new VertxOptions()
               
.setClusterManager(mgr)
               
.setClustered(true);

and 2 simple verticle

package ru.dellin.math.solver.gurobi.javadeployerverticle;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.eventbus.EventBus;

public class Resiver extends AbstractVerticle {
   
   
@Override
   
public void start(){
       
       
EventBus eb = vertx.eventBus();
       
        eb
.consumer("serverVerticle", message->{
           
System.out.println(message.body().toString());
       
});
       
       
System.out.println("-- "+this.getClass().getName()+" --");
       
   
}

}

package ru.dellin.math.solver.gurobi.javadeployerverticle;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.eventbus.EventBus;

public class Sender extends AbstractVerticle {
   
   
@Override
   
public void start(){
       
       
EventBus eb = vertx.eventBus();
       
        vertx
.setPeriodic(2000, handler->{
            eb
.send("serverVerticle", "test"
                   
, res->{
               
if (res.succeeded()){
                   
System.out.println("Received reply");
               
} else {
                   
System.out.println(" No reply");
                    res
.cause().printStackTrace();
               
}
           
}
                   
);            
       
});
       
       
System.out.println("-- "+this.getClass().getName()+" --");
       
   
}
}

when I run on a single machine is all well and messages appear. But when i run Resiver on machine 10.130.58.16 and Sender on machine 10.130.58.254 i see (on 10.130.58.254):

INFO: [10.130.58.254]:40000 [dev] [3.5.2] Creating TcpIpJoiner
сен 15, 2016 6:19:32 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Address[10.130.58.254]:40000 is STARTING
сен 15, 2016 6:19:32 PM com.hazelcast.nio.tcp.SocketConnector
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Connecting to /10.130.58.16:40000, timeout: 0, bind-any: true
сен 15, 2016 6:19:32 PM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Established socket connection between /10.130.58.254:39367
сен 15, 2016 6:19:39 PM com.hazelcast.cluster.ClusterService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2]

Members [2] {
   
Member [10.130.58.16]:40000
   
Member [10.130.58.254]:40000 this
}

сен 15, 2016 6:19:41 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Address[10.130.58.254]:40000 is STARTED
-- ru.dellin.math.solver.gurobi.javadeployerverticle.Sender --
 
No reply
(TIMEOUT,-1) Timed out waiting for a reply
    at io
.vertx.core.eventbus.impl.HandlerRegistration.sendAsyncResultFailure(HandlerRegistration.java:117)
    at io
.vertx.core.eventbus.impl.HandlerRegistration.lambda$new$147(HandlerRegistration.java:64)
    at io
.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:738)
    at io
.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:709)
    at io
.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
    at io
.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io
.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java
.lang.Thread.run(Thread.java:745)

when i try set cluster Host own each machine:

        String ipAddress = Inet4Address.getLocalHost().getHostAddress();        

       
VertxOptions options = new VertxOptions()
               
.setClusterHost(ipAddress)
               
.setClusterManager(mgr)
               
.setClustered(true);

i get the same error

сен 15, 2016 6:26:27 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Address[10.130.58.254]:40000 is STARTING
сен 15, 2016 6:26:27 PM com.hazelcast.nio.tcp.SocketConnector
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Connecting to /10.130.58.16:40000, timeout: 0, bind-any: true
сен 15, 2016 6:26:27 PM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Established socket connection between /10.130.58.254:45033
сен 15, 2016 6:26:34 PM com.hazelcast.cluster.ClusterService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2]

Members [2] {
   
Member [10.130.58.16]:40000
   
Member [10.130.58.254]:40000 this
}

сен 15, 2016 6:26:36 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Address[10.130.58.254]:40000 is STARTED
-- ru.dellin.math.solver.gurobi.javadeployerverticle.Sender --
 
No reply
(TIMEOUT,-1) Timed out waiting for a reply
    at io
.vertx.core.eventbus.impl.HandlerRegistration.sendAsyncResultFailure(HandlerRegistration.java:117)
    at io
.vertx.core.eventbus.impl.HandlerRegistration.lambda$new$147(HandlerRegistration.java:64)
    at io
.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:738)
    at io
.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:709)
    at io
.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
    at io
.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io
.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java
.lang.Thread.run(Thread.java:745)

when i try set cluster Host the same each machine:

        VertxOptions options = new VertxOptions()
               
.setClusterHost("10.130.58.16")
               
.setClusterManager(mgr)
               
.setClustered(true);

on machine 10.130.58.224 I see:

Members [2] {
   
Member [10.130.58.16]:40000
   
Member [10.130.58.254]:40000 this
}

сен 15, 2016 6:33:51 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.58.254]:40000 [dev] [3.5.2] Address[10.130.58.254]:40000 is STARTED
сен 15, 2016 6:33:52 PM io.vertx.core.impl.VertxImpl
SEVERE
: Failed to start event bus
java
.net.BindException: Невозможно назначить запрошенный адрес (
Cannot assign requested address)

    at sun
.nio.ch.Net.bind0(Native Method)
    at sun
.nio.ch.Net.bind(Net.java:433)
    at sun
.nio.ch.Net.bind(Net.java:425)
    at sun
.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun
.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at io
.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
    at io
.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:485)
    at io
.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1089)
    at io
.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:440)
    at io
.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:425)
    at io
.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:903)
    at io
.netty.channel.AbstractChannel.bind(AbstractChannel.java:198)
    at io
.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:348)
    at io
.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io
.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java
.lang.Thread.run(Thread.java:745)

on both machines port is open:
nostroumov@mm-sky-009:~$ ss -lnp | grep 40000
tcp    LISTEN    
0      100                   :::40000                :::*    

what else I can try that to solve this problem? Thanks for your help.


Евгений Мартын

unread,
Sep 16, 2016, 5:55:12 AM9/16/16
to vert.x

the problem was that Inet4Address.getLocalHost().getHostAddress() in Unix returns 127.0.0.1

solution is
    public static String getCurrentIp() {
       
try {
           
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface
                   
.getNetworkInterfaces();
           
while (networkInterfaces.hasMoreElements()) {
               
NetworkInterface ni = (NetworkInterface) networkInterfaces
                       
.nextElement();
               
Enumeration<InetAddress> nias = ni.getInetAddresses();
               
while(nias.hasMoreElements()) {
                   
InetAddress ia= (InetAddress) nias.nextElement();
                   
if (!ia.isLinkLocalAddress()
                     
&& !ia.isLoopbackAddress()
                     
&& ia instanceof Inet4Address) {
                       
return ia.getHostAddress();
                   
}
               
}
           
}
       
} catch (SocketException e) {
           
System.out.println("unable to get current IP ");
            e
.printStackTrace();
       
}
       
return null;
   
}

Do VertxOptions().setClusterHost operate only with ip4 or can use ip6 ?

Dipak Sutariya

unread,
Oct 9, 2017, 6:23:32 AM10/9/17
to vert.x
Hi,
I had same problem with clustered vertx and I tried same solution but still I am facing   
 Timed out after waiting 120000(ms) for a reply. address: 21549c24-4082-44f0-bd74-07667b107c19, repliedAddress: tripReq
        at io.vertx.core.eventbus.impl.HandlerRegistration.sendAsyncResultFailure(HandlerRegistration.java:118)
        at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$new$0(HandlerRegistration.java:65)
        at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:812)
        at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:775)
        at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
        at java.lang.Thread.run(Thread.java:748)
I using latest vertx 3.4.2 

Can you help me why getting time out ?

Thomas SEGISMONT

unread,
Oct 9, 2017, 6:38:09 AM10/9/17
to ve...@googlegroups.com
Can you provide more details, or even better,  a reproducer?

--
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.
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/2322f98f-1ecd-4bc1-8a25-eac11cad42c4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dipak Sutariya

unread,
Oct 9, 2017, 9:21:43 AM10/9/17
to vert.x
Hi Thomas,

Thanks you for reply.

My vertx process working fine without cluster.

if I am clustering using TCP/Ip and it is clustered fine and creating two clustered vertx instance.
but when we using send method of event bus some time it is working fine and some time getting time out.

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.

Thomas SEGISMONT

unread,
Oct 9, 2017, 10:49:02 AM10/9/17
to ve...@googlegroups.com
Thanks that does not sound right. I would need a simple reproducer. Thank you

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

Dipak Sutariya

unread,
Oct 10, 2017, 2:36:23 AM10/10/17
to vert.x
Hi Tomas,

Please find attached project.

eventBus.send method getting time out in cluster vertx without cluster it is working fine.

After clustered call vertx using below code from main method.

String requestContent="{}";
try {
    // long startTime=System.currentTimeMillis();
    //System.out.println("Start blocking call on AsyncTripProcessor: "+startTime);
       JsonObject headers = new JsonObject();
       //headers.put("action", "send");
       headers.put("timeout", "120000");

       JsonObject body = new JsonObject();
       body.put("tripReq",requestContent);

       JsonObject protocol = new JsonObject();
       protocol.put("type", "send");
       protocol.put("headers", headers);
       protocol.put("body", body);
       protocol.put("address", "requestContent");
       protocol.put("replyAddress", "#backtrack");


       Buffer buffer = Buffer.buffer();
       buffer.appendInt(protocol.encode().getBytes().length);
       buffer.appendString(protocol.encode());             
       Socket clientSocket =new test1().getActiveSocket("192.168.55.102:7000");//you can pass comma separated ip and port             
       if(!clientSocket.isConnected())
       {
        System.out.println("Can not connect to vertx process");
       }
       clientSocket.setSoTimeout(0);
       DataOutputStream output = new DataOutputStream(clientSocket.getOutputStream());
       output.write(buffer.getBytes());

       DataInputStream input = new DataInputStream(clientSocket.getInputStream());

       int bytesLength = input.readInt();
       byte[] bytes = new byte[bytesLength];
       for(int i = 0; i < bytesLength; i++) {
         bytes[i] = input.readByte();
       }        
       input.close();
       output.close();
       clientSocket.close();

       JsonObject reply = new JsonObject(new String(bytes));

       // is there an error?
       if (reply.containsKey("failureType")){
        System.out.println("Bytes length "+bytesLength+" "+new String(bytes));
       
       }
       else {
        System.out.println(reply.getJsonObject("body").getString("reponse"));
       }
     //  System.out.println("End blocking call on AsyncTripProcessor: "+(System.currentTimeMillis()-startTime));
      // f.complete();
       

     } catch (IOException e) {
       //f.fail(e);
DummyTripVertx.zip

Dipak Sutariya

unread,
Oct 10, 2017, 9:05:35 AM10/10/17
to vert.x
Hi Tomas,

I have resolved  this problem after setting ClusterPublicHost and port in EventBusOptions.
Thanks,
Dipak

Thomas SEGISMONT

unread,
Oct 11, 2017, 3:38:41 PM10/11/17
to ve...@googlegroups.com
Good to know. Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages