相关文章推荐
销魂的风衣  ·  java - ...·  1 年前    · 
忐忑的感冒药  ·  java - Closing JPA ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

java.util.concurrent.TimeoutException: Futures timed out after [3000 milliseconds] When creating akka actorSystem

Ask Question loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = "DEBUG" logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" actor { provider = "akka.cluster.ClusterActorRefProvider" creation-timeout = 20s warn-about-java-serializer-usage = on enable-additional-serialization-bindings = on remote { log-remote-lifecycle-events = off log-frame-size-exceeding = 15 MiB artery { enabled = on canonical { port = 2551 advanced { maximum-frame-size = 15 MiB buffer-pool-size = 1024 maximum-large-frame-size = 15 MiB large-buffer-pool-size = 4096 outbound-message-queue-size = 4096 outbound-control-queue-size = 20000 outbound-large-message-queue-size = 4096 cluster { seed-node-timeout = 15s retry-unsuccessful-join-after = 15s shutdown-after-unsuccessful-join-seed-nodes = off auto-down-unreachable-after = off seed-nodes = ["akka://ClusterSystem@SERVER1:2551", "akka://ClusterSystem@SERVER2:2551"]

Actor System is created using -

package com.mycompany.akka;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import akka.actor.ActorSystem;
public class ActorSystemFactory {
    public static ActorSystem getActorSystem() {
        try {
            String hostName = String hostName = InetAddress.getLocalHost().getHostName();
            Config cfg = ConfigFactory.parseString(
                    "akka.remote.artery.canonical.hostname=" + hostName).withFallback(
                    ConfigFactory.load());
            String prop = System.getProperty("cluster_name");
            if (prop == null)
                throw new Exception("property cluster_name is not set");
            ActorSystem as = ActorSystem.create(prop, cfg);
            return as;
        } catch ( Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);

Consistently I'm able to see actor system is shutdown with below error -

java.lang.RuntimeException: java.util.concurrent.TimeoutException: Futures timed out after [3000 milliseconds]
    at com.mycompany.akka.ActorSystemFactory.getActorSystem(ActorSystemFactory.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 25 more
Caused by: java.util.concurrent.TimeoutException: Futures timed out after [3000 milliseconds]
    at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:223)
    at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:227)
    at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:190)
    at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
    at scala.concurrent.Await$.result(package.scala:190)
    at akka.remote.artery.aeron.ArteryAeronUdpTransport.retry$1(ArteryAeronUdpTransport.scala:235)
    at akka.remote.artery.aeron.ArteryAeronUdpTransport.blockUntilChannelActive(ArteryAeronUdpTransport.scala:232)
    at akka.remote.artery.aeron.ArteryAeronUdpTransport.runInboundStreams(ArteryAeronUdpTransport.scala:347)
    at akka.remote.artery.ArteryTransport.start(ArteryTransport.scala:467)
    at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:234)
    at akka.cluster.ClusterActorRefProvider.init(ClusterActorRefProvider.scala:40)
    at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:912)
    at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:908)
    at akka.actor.ActorSystemImpl._start(ActorSystem.scala:908)
    at akka.actor.ActorSystemImpl.start(ActorSystem.scala:930)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:258)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:302)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:276)
    at akka.actor.ActorSystem$.create(ActorSystem.scala:199)
    at akka.actor.ActorSystem.create(ActorSystem.scala)
    at com.mycompany.akka.ActorSystemFactory.getActorSystem(ActorSystemFactory.java:22)
    ... 30 more

akka version - 2.5.25 scala version - 2.11

What is the issue with actor system and how can I fix this?

Working Solution:

I also had to struggle to find out exact solution and here it is based on the exception I could find. You have to add bind.bind-timeout in your akka -> actor -> remote -> artery -> bind configuration.

  remote.artery {
    # The port clients should connect to.
    canonical.port = 2551
    bind.bind-timeout = 30s
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.