Max*_*ich 3 c# akka-remote-actor akka.net akka-remoting
我发现的所有演示都展示了如何在Akka.NET中进行远程处理,所有演示均展示了最简单的用例,其中两个参与者使用本地主机在同一台计算机上运行。
我试图让Akka.NET actor连接到远程计算机,并遇到了一些困难。
代码非常简单:
客户代码:
var config = ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = DEBUG
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
deployment {
/remoteactor {
router = round-robin-pool
nr-of-instances = 5
remote = ""akka.tcp://system2@xxx.australiasoutheast.cloudapp.azure.com:666""
}
}
}
remote {
dot-netty.tcp {
port = 0
hostname = localhost
}
}
}
");
using (var system = ActorSystem.Create("system1", config))
{
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
服务器代码:
var config = ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = DEBUG
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
remote {
dot-netty.tcp {
transport-protocol = tcp
port = 666
hostname = ""10.0.0.4"" //This is the local IP address
}
}
}
");
using (ActorSystem.Create("system2", config))
{
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
当我在本地网络上的另一台计算机上运行actor进程时,我可以成功连接,但是当我将相同的简单示例分发到云VM上时,出现以下错误:
[ERROR][11/9/2017 3:58:45 PM][Thread 0008][[akka://system2/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fsystem1%40localhost%3A28456-1/endpointWriter#1657012126]] Dropping message [Akka.Remote.DaemonMsgCreate] for non-local recipient [[akka.tcp://system2@xxx.australiasoutheast.cloudapp.azure.com:666/remote]] arriving at [akka.tcp://system2@xxx.australiasoutheast.cloudapp.azure.com:666] inbound addresses [akka.tcp://system2@10.0.0.4:666]
Cause: Unknown
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用“ 127.0.0.1”,但这似乎在本地或网络上均不起作用。
有人可以提供关于我可能做错了什么的任何输入吗?
更新:
我试图使用Akka.NET中可用的bind-hostname和bind-port选项,因为这应该可以解决我认为自己正在遭受的NAT问题。不幸的是,这似乎也不起作用,我尝试了各种配置选项,例如使用主机名和IP地址,如下所示:
remote {
dot-netty.tcp {
port = 666
hostname = "13.73.xx.xx"
bind-port = 666
bind-hostname = "0.0.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试上述配置时收到的错误消息是:
[ERROR][11/12/2017 5:19:58 AM][Thread 0003][Akka.Remote.Transport.DotNetty.TcpTransport] Failed to bind to 13.73.xx.xx:666; shutting down DotNetty transport.
Cause: System.AggregateException: One or more errors occurred. ---> System.Net.Sockets.SocketException: The requested address is not valid in its context
Run Code Online (Sandbox Code Playgroud)
几点评论:
在您的服务器配置中将其绑定到0.0.0.0。(hostname = 0.0.0.0)这样,如果您的云托管环境使用多个网络终结点,则套接字将绑定到所有本地终结点。然后使用设置public-hostname = xxx.australiasoutheast.cloudapp.azure.com。这样,服务器实例的主机名与您在远程URL中使用的远程地址相同。
请注意,公用主机名(如果未使用公用主机名,则为主机名)必须是DNS可解析的。
| 归档时间: |
|
| 查看次数: |
1236 次 |
| 最近记录: |