How to make Akka.NET's ClusterClient work?

407 views Asked by At

I'm trying out ClusterClient as per the docs.

However my client test app keeps getting the following error:

Error while creating actor instance of type Akka.Cluster.Tools.Client.ClusterClient with 1 args: (Akka.Cluster.Tools.Client.ClusterClientSettings)
Cause: [akka://TestSystem/user/$a#705838478]: Akka.Actor.ActorInitializationException: Exception during creation ---> System.TypeLoadException: Error while creating actor instance of type Akka.Cluster.Tools.Client.ClusterClient with 1 args: (Akka.Cluster.Tools.Client.ClusterClientSettings) ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: failure-detector.heartbeat-interval must be > 0s
   at Akka.Remote.DeadlineFailureDetector..ctor(TimeSpan acceptableHeartbeatPause, TimeSpan heartbeatInterval, Clock clock)
   at Akka.Remote.DeadlineFailureDetector..ctor(TimeSpan acceptableHeartbeatPause, Clock clock)
   at Akka.Cluster.Tools.Client.ClusterClient..ctor(ClusterClientSettings settings)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Akka.Actor.Props.ActivatorProducer.Produce()
   at Akka.Actor.Props.NewActor()
   --- End of inner exception stack trace ---
   at Akka.Actor.Props.NewActor()
   at Akka.Actor.ActorCell.CreateNewActorInstance()
   at Akka.Actor.ActorCell.<>c__DisplayClass118_0.<NewActor>b__0()
   at Akka.Actor.ActorCell.UseThreadContext(Action action)
   at Akka.Actor.ActorCell.NewActor()
   at Akka.Actor.ActorCell.Create(Exception failure)
   --- End of inner exception stack trace ---
   at Akka.Actor.ActorCell.Create(Exception failure)
   at Akka.Actor.ActorCell.SysMsgInvokeAll(EarliestFirstSystemMessageList messages, Int32 currentState)

The minimal code I'm using to get this error:

using (var system = ActorSystem.Create("TestSystem")) {
    system.Settings.InjectTopLevelFallback(ClusterClientReceptionist.DefaultConfig());
    var settings = ClusterClientSettings.Create(system);
    var client = system.ActorOf(ClusterClient.Props(settings));
    Console.Write("Press any key to exit...");
    Console.ReadKey();
}

The HOCON config for the client contains:

akka {
  actor {
    provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
  }

  remote {
    helios.tcp {
      port = 0
      hostname = localhost
    }
  }

  cluster {
    client {
      initial-contacts: ["akka.tcp://TestSystem@localhost:8082/user/receptionist"]
    }
  }
}

Also checked the settings variable, seemed to be populated and looks ok to me:

settings variable content

Tried several random stuff to actually fulfill the error message:

failure-detector.heartbeat-interval must be > 0s

including various permutation of HOCON entries, but to no avail.

Anything else I missed out?

Update #1

Modified HOCON to initialize Akka.Remote. Still received what looks like the same error message.

But now it is stating:

failure-detector.heartbeat-interval must be > 0s

Previously it was stating:

failure-detector.acceptable-heartbeat-pause must be >= 0s

1

There are 1 answers

0
Amry On

Managed to make it working now.

The cause of the issue: I was using Akka.Cluster.Tools latest release version 1.0.6

The fix: Upgraded to the latest beta version 1.1.2.30-beta

p/s: I wished the docs could have specified the minimum NuGet version required to make it work.