我发现的演示演示了如何在Akka.NET中开始远程处理,演示了两个参与者使用本地主机在同一台机器上运行的最简单的用例。
我试图让一个Akka.NET演员连接到一台远程机器,但遇到了一些困难。
代码非常简单:
客户端代码:
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();
}服务器代码:
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();
}当我在本地网络上的另一台计算机上运行参与者进程时,我可以成功地连接,但是当我将相同的简单示例分发到云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我也尝试过使用"127.0.0.1“,但这似乎在本地或网上都不起作用。
有人能提供任何关于我可能做错了什么的意见吗?
更新
我已经尝试使用Akka.NET中可用的绑定主机名和绑定端口选项,因为这应该是为了绕过NAT问题,我认为我正在遭受痛苦。不幸的是,这似乎也不起作用,我尝试了各种配置选项,例如使用主机名和IP地址,如下所示:
remote {
dot-netty.tcp {
port = 666
hostname = "13.73.xx.xx"
bind-port = 666
bind-hostname = "0.0.0.0"
}
}当我尝试上述配置时收到的错误消息是:
[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发布于 2017-11-13 10:59:01
几点意见:
在您的服务器配置中,将其绑定到0.0.0.0。(hostname = 0.0.0.0)如果云托管env使用多个网络端点,套接字将绑定到所有本地端点。然后使用设置public-hostname = xxx.australiasoutheast.cloudapp.azure.com。这样,服务器实例的主机名与您在远程处理url中使用的远程处理地址相同。
请注意,公共主机名(和主机名,如果不使用公共主机名)必须是DNS可解析的。
https://stackoverflow.com/questions/47206602
复制相似问题