Akka.NET:致远程演员的死信

问题描述

我正在学习如何从其他机器呼叫远程角色。为了模拟两台不同的计算机,我有一台主机,另一台是虚拟机(VM)。网络适​​配器设置为reduce,因为通过此设置,我可以从VM对主机进行ping操作(我读到应将其设置为Bridge,但ping命令超时)。

NAT

此外,这是主机上Host IP: 172.16.104.242 VM IP: 10.0.2.15 代码

RemoteActor.fsx

我首先执行了此脚本,这是输出

enter image description here

这是VM上#r "nuget: Akka.FSharp" #r "nuget: Akka.Remote" open System open Akka.Actor open Akka.Configuration open Akka.FSharp let config = Configuration.parse @"akka { actor.provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" remote.helios.tcp { hostname = 172.16.104.242 port = 9001 } }" let system = System.create "RemoteFSharp" config let echoServer = spawn system "EchoServer" <| fun mailBox -> let rec loop() = actor { let! message = mailBox.Receive() let sender = mailBox.Sender() printfn "echoServer called" match Box message with | :? string -> sender <! sprintf "Echo: %s" message return! loop() | _ -> failwith "UnkNown message" } loop() 代码

LocalActor.fsx

这是此的输出

Local Remote

现在#r "nuget: Akka.FSharp" #r "nuget: Akka.Remote" open System open Akka.Actor open Akka.Configuration open Akka.FSharp let configuration = ConfigurationFactory.ParseString( @"akka { actor { provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" deployment { /remoteecho { remote = ""akka.tcp://RemoteFSharp@172.16.104.242:9001"" } } } remote { helios.tcp { port = 0 hostname = 10.0.2.15 } } }") let system = ActorSystem.Create("RemoteFSharp",configuration) let echoClient = system.ActorSelection("akka.tcp://RemoteFSharp@172.16.104.242:9001/EchoServer") let task = echoClient <? "F#!" let response = Async.RunSynchronously (task,1000) printfn "Reply from remote %s" (string(response)) 会引发此错误

Error

我在Stack Overflow上发现了几处同样的错误,但找不到解决方法。显然是因为RemoteActor.fsxRemoteActor发送消息之前死亡。同样,如果我在Local Actor终端中键入此RemoteActor.fsx,则在运行echoServer <! "Hello"脚本之后,也会遇到相同的错误

有人知道如何解决此问题吗?任何帮助将不胜感激!谢谢!

解决方法

更改此行

let echoClient = system.ActorSelection("akka.tcp://RemoteFSharp@172.16.104.242:9001/EchoServer")

收件人

let echoClient = system.ActorSelection("akka.tcp://RemoteFSharp@172.16.104.242:9001/user/EchoServer")

所有用户定义的参与者都存在于/user参与者根下。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...