【发布时间】:2016-08-12 12:22:48
【问题描述】:
我有一个分布式演员系统,一些在 Windows 上,一些在 Linux 机器上。有时一个参与者可能需要连接其他参与者并进行一些通信。当然,也有一种情况是在 Windows 上,另一种在 Linux 系统上。
Actor 通过 ActorSelection 相互连接。问题是,当 Windows 参与者尝试与 Linux 进行通信时,一切正常。但是当 Linux Actor 发起通信时,ActorSelection.ResolveOne 失败。
我在这里做了一个小样本:
static void Main(string[] args)
{
ActorSystem system = ActorSystem.Create("TestSystem");
system.ActorOf(Props.Create(() => new ConnectActor()), "test");
while (true)
{
var address = Console.ReadLine();
if (string.IsNullOrEmpty(address))
{
system.Terminate();
return;
}
var remoteAddress = $"akka.tcp://{system.Name}@{address}/user/test";
try
{
var actor = system.ActorSelection(remoteAddress).ResolveOne(TimeSpan.FromMilliseconds(5000)).Result;
Console.WriteLine("Resolved: " + actor.Path);
}
catch (Exception ex)
{
Console.WriteLine("Failed: " + ex.Message);
}
}
}
app.config 中的配置如下:
akka {
loggers = ["Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog"]
suppress-json-serializer-warning = on
loglevel = "DEBUG"
log-config-on-start = on
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
remote {
log-remote-lifecycle-events = DEBUG
log-received-messages = on
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
transport-protocol = tcp
applied-adapters = []
port = 9000
hostname = "0.0.0.0"
public-hostname = "192.168.0.251" // This is different for different hosts, of course
}
}
}
public-hostname 是公开的 ip 地址。
所以,以下是案例:
- 在运行 Windows/Windows 时,两个实例可以互相看到(我给它们远程地址 - 它们输出“已解决”)
- 在运行 Windows/Linux 时,将 linux actor 的地址提供给 windows actor,它会输出“Resolved”。所以windows连接linux没有问题。之后将 Windows Actor 的地址提供给 linux Actor 也会给出“已解决” - 我想,连接已经建立并且没有真正的握手传递
- 但是当运行 Windiws/Linux 并将 windows actor 的地址提供给 linux actor 时,它给出“失败”。没有关于任何错误或丢弃包的消息。在日志的末尾有以下内容:
Akka.Remote.Transport.AkkaProtocolManager|现在监督 akka://TestSystem/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3A%2F%2FTestSystem%40%5B%3A%3Affff%3A192.168.0 .252%5D%3A36983-1|||| 13:20:08.3766|DEBUGAkka.Remote.Transport.ProtocolStateActor|开始 (Akka.Remote.Transport.ProtocolStateActor)|||| 13:20:08.3922|调试|Akka.Remote.Transport.ProtocolStateActor|已停止||||
此处描述了类似日志的问题:Akka.net starting and stopping with no activity 原因是系统协议不兼容。这是同一个问题吗?正如我从 Akka.NET 文档和发行说明中获得的那样,它具有完整的 linux 支持......
那么,我是否在配置中遗漏了什么?任何人都可以让这个示例与 Linux -> Windows 连接一起使用吗?
【问题讨论】: