In cluster mode,i using the Await.result(Future<?>,Duration) method causes a block

I developed a cluster with two nodes using the java language.Start node A and node B.When node B starts,an actor is created named “/user/bactor”.Remotely access the actors in node B from node A:

Timeout timeout = new Timeout(2000,TimeUnit.SECONDS);
AskableActorSelection asker = new AskableActorSelection(sel);
Future<Object> future = asker.ask(new Identify(1),);
ActorIdentity ident = (ActorIdentity) Await.result(future,timeout.duration());

At this time ,the above code is OK.Then,after stopping node B,send the request again , the console will also print exceptions and it will block in “Await.result()”.Exception are as follows :

Caller+0 at akka.event.slf4j.Slf4jLogger$$anonfun$receive$1.$anonfun$applyOrElse$2(Slf4jLogger.scala:92)
[outbound connection to [akka://test@], message stream] Upstream failed , cause: StreamTcpException:Tcp command [Connect(,None,List(),Some(5000 milliseconds),true)]
failed because of refused : no further information

That’s what I would expect. What is your expected result?

You are receiving (warning) connection failures because the cluster has lost a member (node B) and it is dealing with that failure. (As it should.)

You are blocking at the ask because it’s never going to get a response from an actor that doesn’t exist. (As it should.)

1 Like

Thanks for your answer.As you said,i can understand.But how can i end the blocking state?
In addition , when i only start node A , similarly,executing this code will not block,which makes me a little confused.