微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为非本地收件人删除消息[Akka.Actor.ActorSelectionMessage]

如何解决为非本地收件人删除消息[Akka.Actor.ActorSelectionMessage]

我希望两个演员交流。我的本地计算机上有一个本地系统(客户端),而EC2上有一个远程actor(服务器)。但是我无法从客户端系统向远程参与者发送消息。

testClient.fs

#if INteraCTIVE
#time "on"
#r "nuget: Akka.FSharp" 
#r "nuget: Akka.TestKit" 
#endif

open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open System.Collections.Generic

let configuration = 
                    ConfigurationFactory.ParseString(
                        @"akka {
                            actor {
                                provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote""
                            }
                            remote {
                             transport = ""akka.remote.netty.NettyRemoteTransport""
                             netty {
                               hostname = localhost
                               port = 0
                             }
                           }
                        }")

let system = ActorSystem.Create("System",configuration)

[<EntryPoint>]
let main args =               
    let remoteClient = system.ActorSelection(
                            "akka.tcp://RemoteSystem@A.B.C.D:2552/user/remoteActor")
    printfn "%A" remoteClient
    remoteClient <! "message from client"
    Console.ReadLine() |> ignore
    0

testServer.fs

#if INteraCTIVE
#time "on"
#r "nuget: Akka.FSharp" 
#r "nuget: Akka.TestKit" 
#endif
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open System.Collections.Generic

let helper msg = printfn "hello from server : %A" msg

let configuration = 
                    ConfigurationFactory.ParseString(
                        @"akka {
                            actor {
                                provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote""
                            }
                            remote {
                             transport = ""akka.remote.netty.NettyRemoteTransport""
                             netty {
                               hostname = ""A.B.C.D""
                               port = 2552
                             }
                           }
                        }")

let remoteSystem = ActorSystem.Create("RemoteSystem",configuration)

let createActor (f : 'a -> unit) = actorOf f

[<EntryPoint>]
let main args =  
  let remoteActor = createActor helper |> spawn remoteSystem "remoteActor"
  Console.ReadLine() |> ignore
  0

首先,当我启动服务器和运行客户端时,它们依次查找远程actor并发送消息。然后我在EC2的服务器中收到以下错误

[INFO] [09/25/2020 19:20:07] [线程0001] [远程(akka:// RemoteSystem)]开始远程 [INFO] [09/25/2020 19:20:08] [线程0001] [远程处理(akka:// RemoteSystem)]远程处理已开始;监听地址:[akka.tcp://RemoteSystem@0.0.0.0:2552] [INFO] [09/25/2020 19:20:08] [线程0001] [远程处理(akka:// RemoteSystem)]远程处理现在侦听地址:[akka.tcp://RemoteSystem@0.0.0.0:2552] [akka:// RemoteSystem / user / remoteActor#1987516675] [错误] [09/25/2020 19:20:23] [线程0007] [akka.tcp://RemoteSystem@0.0.0.0:2552 / system / endpointManager / reliableEndpointWriter-akka.tcp%3A%2F%2FSystem% 400.0.0.0%3A2552-1 / endpointWriter]丢弃到达[akka.tcp:// RemoteSystem]的非本地收件人[[akka.tcp:// RemoteSystem @ ABCD:2552 /]]的消息[Akka.Actor.ActorSelectionMessage] @ABCD:2552]入站地址[akka.tcp://RemoteSystem@0.0.0.0:2552]

当我运行它时,在客户端sie上输出

[INFO] [9/25/2020 7:20:21 PM] [线程0001] [远程处理(akka:// System)]开始远程处理 [INFO] [9/25/2020 7:20:22 PM] [线程0001] [远程处理(akka:// System)]远程处理已开始;监听地址:[akka.tcp://System@0.0.0.0:2552] [INFO] [9/25/2020 7:20:22 PM] [线程0001] [远程处理(akka:// System)]远程处理现在侦听地址:[akka.tcp://System@0.0.0.0:2552 ] ActorSelection [Anchor(akka.tcp://RemoteSystem@A.B.C.D:2552 /),Path(/ user / remoteActor)]

然后我在此错误中进行了大量搜索,并在服务器上的配置文件中尝试了以下选项 public-hostname =本地主机, bind-hostname =“” A1.B1.C1.D1“”,其中“” A1.B1.C1.D1“”是EC2实例的私有IP地址, 绑定端口= 2552

可能是什么错误?关于如何解决它的任何想法?谢谢

解决方法

我的猜测是这是由于涉及到NAT。您需要告诉Akka您的外部/内部主机名是什么:

https://doc.akka.io/docs/akka/current/remoting.html#akka-behind-nat-or-in-a-docker-container

如果涉及2个NAT级别,则可能需要一些额外的跟踪和错误。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?