我正在尝试构建一个小型的AKka.NET集群应用程序,但是我遇到了问题,因为我一直收到以下错误:
[WARNING][7/14/2022 10:42:06 AM][Thread 0011][akka.tcp://accountsystem@localhost:57959/system/cluster/core/daemon/joinSeedNodeProcess-1] Couldn't join seed nodes after [2] attempts, will try again. seed-nodes=[akka.tcp://accountsystem@localhost:2551]这是我的灯塔服务的对接文件:
version: '3'
services:
accountsystem.lighthouse:
image: petabridge/lighthouse:latest
hostname: accountsystem.lighthouse
ports:
- '2551:2551'
environment:
ACTORSYSTEM: "accountsystem"
CLUSTER_PORT: 2551
CLUSTER_IP: "accountsystem.lighthouse"
CLUSTER_SEEDS: "akka.tcp://accountsystem@accountsystem.lighthouse:2551"这是我的AKka.NET配置:
<![CDATA[
akka {
actor {
provider = cluster
}
remote {
log-remote-lifecycle-events = DEBUG
dot-netty.tcp {
hostname = "localhost"
port = 0
}
}
cluster {
seed-nodes = [
"akka.tcp://accountsystem@localhost:2551"]
#auto-down-unreachable-after = 30s
}
}
]]>此外,我还将共享我的AKkaService代码设置。
public Task StartAsync(CancellationToken cancellationToken)
{
var akkaConfig = (AkkaConfigurationSection) System.Configuration.ConfigurationManager.GetSection("akka");
var bootstrap = BootstrapSetup.Create()
.WithConfig(akkaConfig.AkkaConfig)
.WithActorRefProvider(ProviderSelection.Cluster.Instance); // launch Akka.Cluster
// enable DI support inside this ActorSystem, if needed
var diSetup = DependencyResolverSetup.Create(_serviceProvider);
// merge this setup (and any others) together into ActorSystemSetup
var actorSystemSetup = bootstrap.And(diSetup);
// start ActorSystem
_actorSystem = ActorSystem.Create("accountsystem", actorSystemSetup);
var props = DependencyResolver.For(_actorSystem).Props<AccountRouterActor>();
_actorRef = _actorSystem.ActorOf(props, "account");
_actorSystem.WhenTerminated.ContinueWith(tr => {
_applicationLifetime.StopApplication();
});
return Task.CompletedTask;
}我一直在阅读关于参与者系统和服务器不匹配的文章,但是我认为这个名字是正确的,那就是accountsystem。我也是共享我的控制台后,启动我的码头撰写文件与所有的消息。也许这会有帮助。
docker-compose up
WARNING: Found orphan containers (accountpoc_mssql_1, mysql) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Starting accountpoc_accountsystem.lighthouse_1 ... done
Attaching to accountpoc_accountsystem.lighthouse_1
accountsystem.lighthouse_1 | [Docker-Bootstrap] IP=accountsystem.lighthouse
accountsystem.lighthouse_1 | [Docker-Bootstrap] PORT=2551
accountsystem.lighthouse_1 | [Docker-Bootstrap] SEEDS=["akka.tcp://accountsystem@accountsystem.lighthouse:2551"]
accountsystem.lighthouse_1 | [Lighthouse] ActorSystem: accountsystem; IP: accountsystem.lighthouse; PORT: 2551
accountsystem.lighthouse_1 | [Lighthouse] Performing pre-boot sanity check. Should be able to parse address [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [Lighthouse] Parse successful.
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][remoting (akka://accountsystem)] Starting remoting
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][remoting (akka://accountsystem)] Remoting started; listening on addresses : [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][remoting (akka://accountsystem)] Remoting now listens on addresses: [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][Cluster (akka://accountsystem)] Cluster Node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] - Starting up...
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][Cluster (akka://accountsystem)] Cluster Node [1.6.2] - Node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] is JOINING itself (with roles [lighthouse], version [1.6.2]) and forming a new cluster
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][Cluster (akka://accountsystem)] Cluster Node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] - is the new leader among reachable nodes (more leaders may exist)
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:48][Thread 0001][Cluster (akka://accountsystem)] Cluster Node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] - Leader is moving node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] to [Up]
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:49][Thread 0001][Cluster (akka://accountsystem)] Cluster Node [akka.tcp://accountsystem@accountsystem.lighthouse:2551] - Started up successfully
accountsystem.lighthouse_1 | [INFO][07/14/2022 10:52:49][Thread 0001][akka.tcp://accountsystem@accountsystem.lighthouse:2551/user/petabridge.cmd] petabridge.cmd host bound to [0.0.0.0:9110]
accountsystem.lighthouse_1 | [ERROR][07/14/2022 10:52:58][Thread 0008][akka.tcp://accountsystem@accountsystem.lighthouse:2551/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Faccountsystem%40localhost%3A59968-1/endpointWriter] Dropping message [Akka.Actor.ActorSelectionMessage] for non-local recipient [[akka.tcp://accountsystem@localhost:2551/]] arriving at [akka.tcp://accountsystem@localhost:2551] inbound addresses [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [ERROR][07/14/2022 10:53:02][Thread 0008][akka.tcp://accountsystem@accountsystem.lighthouse:2551/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Faccountsystem%40localhost%3A59968-1/endpointWriter] Dropping message [Akka.Actor.ActorSelectionMessage] for non-local recipient [[akka.tcp://accountsystem@localhost:2551/]] arriving at [akka.tcp://accountsystem@localhost:2551] inbound addresses [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [ERROR][07/14/2022 10:53:08][Thread 0008][akka.tcp://accountsystem@accountsystem.lighthouse:2551/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Faccountsystem%40localhost%3A59968-1/endpointWriter] Dropping message [Akka.Actor.ActorSelectionMessage] for non-local recipient [[akka.tcp://accountsystem@localhost:2551/]] arriving at [akka.tcp://accountsystem@localhost:2551] inbound addresses [akka.tcp://accountsystem@accountsystem.lighthouse:2551]
accountsystem.lighthouse_1 | [WARNING][07/14/2022 10:53:10][Thread 0008][akka.tcp://accountsystem@accountsystem.lighthouse:2551/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Faccountsystem%40localhost%3A59968-1] Association with remote system akka.tcp://accountsystem@localhost:59968 has failed; address is now gated for 5000 ms. Reason is: [Akka.Remote.EndpointDisassociatedException: Disassociated
accountsystem.lighthouse_1 | at Akka.Remote.EndpointWriter.PublishAndThrow(Exception reason, LogLevel level, Boolean needToThrow)
accountsystem.lighthouse_1 | at Akka.Remote.EndpointWriter.Unhandled(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.UntypedActor.Receive(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.ReceiveMessage(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.ReceivedTerminated(Terminated t)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.AutoReceiveMessage(Envelope envelope)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.Invoke(Envelope envelope)]
accountsystem.lighthouse_1 | [ERROR][07/14/2022 10:53:10][Thread 0008][akka://accountsystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Faccountsystem%40localhost%3A59968-1/endpointWriter] Disassociated
accountsystem.lighthouse_1 | Cause: Akka.Remote.EndpointDisassociatedException: Disassociated
accountsystem.lighthouse_1 | at Akka.Remote.EndpointWriter.PublishAndThrow(Exception reason, LogLevel level, Boolean needToThrow)
accountsystem.lighthouse_1 | at Akka.Remote.EndpointWriter.Unhandled(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.UntypedActor.Receive(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.ReceiveMessage(Object message)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.ReceivedTerminated(Terminated t)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.AutoReceiveMessage(Envelope envelope)
accountsystem.lighthouse_1 | at Akka.Actor.ActorCell.Invoke(Envelope envelope)发布于 2022-07-18 12:59:13
好吧,我只需将hocon配置更改为:
<![CDATA[
akka {
actor {
provider = cluster
}
remote {
log-remote-lifecycle-events = DEBUG
dot-netty.tcp {
hostname = "localhost"
port = 2551
}
}
cluster {
seed-nodes = [
"akka.tcp://accountsystem@localhost:2551"]
#auto-down-unreachable-after = 30s
}
}
]]>发布于 2022-07-19 13:27:36
为了使这些环境变量工作:
CLUSTER_PORT: 2551
CLUSTER_IP: "accountsystem.lighthouse"
CLUSTER_SEEDS: "akka.tcp://accountsystem@accountsystem.lighthouse:2551"您需要安装https://github.com/petabridge/akkadotnet-bootstrap/tree/dev/src/Akka.Bootstrap.Docker并在Config对象上调用BootstrapFromDocker()。灯塔内部就是这么做的。
您还可能发现使用Akka.Cluster.Hosting可以更容易地完成这一任务,因为您现在可以从类型化的Microsoft.Extensions.Configuration部分提取这些值,并以编程方式将它们传递给WithRemoting和WithClustering方法ala:
builder.Services.AddAkka("MyActorSystem", configurationBuilder =>
{
configurationBuilder
.WithRemoting("localhost", 8110)
.WithClustering(new ClusterOptions(){ Roles = new[]{ "myRole" },
SeedNodes = new[]{ Address.Parse("akka.tcp://MyActorSystem@localhost:8110")}})
.WithActors((system, registry) =>
{
var echo = system.ActorOf(act =>
{
act.ReceiveAny((o, context) =>
{
context.Sender.Tell($"{context.Self} rcv {o}");
});
}, "echo");
registry.TryRegister<Echo>(echo); // register for DI
});
});https://stackoverflow.com/questions/72979405
复制相似问题