Akka.net系统看不到远程角色

时间:2019-10-11 11:09:03

标签: akka.net akka-remoting

我有两个包含参与者系统的简单控制台应用程序。每个应用程序都在单独的计算机上运行。我想从第二个应用程序中选择演员并发送消息。

第一

    class Program
    {
        static void Main(string[] args)
        {
            var config = ConfigurationFactory.ParseString(@"
akka {  
    actor {
        provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
    }
    remote {
        dot-netty.tcp {
            port = 8080
            hostname = 0.0.0.0
            public-hostname = 192.168.0.175
        }
    }
}");

            using (var system = ActorSystem.Create("System1", config))
            {
                var actorSelection2 = system.ActorSelection("akka.tcp://System2@192.168.0.152:8082/user/Actor");
                var actor2 = actorSelection2.ResolveOne(TimeSpan.FromSeconds(3)).Result;
                actor2.Tell("Hello from System1!");

                Console.ReadKey();
            }
        }
    }

第二

    class Program
    {
        static void Main(string[] args)
        {
            var config = ConfigurationFactory.ParseString(@"
akka {  
    actor {
        provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
    }
    remote {
        dot-netty.tcp {
            port = 8082
            hostname = 0.0.0.0
            public-hostname = 192.168.0.152
        }
    }
}");

            using (var system = ActorSystem.Create("System2", config))
            {
                var actor = system.ActorOf<Actor>("Actor");
                Console.ReadKey();
            }
        }
    }

    public class Actor : ReceiveActor
    {
        public Actor()
        {
            Receive<string>(msg =>
            {
                Console.WriteLine($"RECEIVE: {msg}");
            });
        }
    }

System1无法解析“演员”,看不到它。这是错误的配置还是网络问题? 知道如何解决此问题吗? 谢谢!

0 个答案:

没有答案