简体   繁体   English

调试 Akka.NET 远程连接(无法连接 - 绑定失败)

[英]Debugging Akka.NET remote connections (Cant connect - Failed to bind)

Using the example Chat Server/Client project available as part of the Akka.NET source code I have attempted to modify it such that it would successfully work over two computers on my network.使用作为 Akka.NET 源代码的一部分提供的示例聊天服务器/客户端项目,我尝试修改它,使其能够在我的网络上的两台计算机上成功运行。

I have two systems that are connected via a router like this我有两个系统通过这样的路由器连接

192.168.0.29 (Server) <---------------| Router |---------------> 192.168.0.52 (Client)

I then have two actor systems that are configured like this:然后我有两个配置如下的actor系统:

Server:服务器:

akka {  
    actor {
        provider = remote #Specify remote provider
    }
    remote {

        dot-netty.tcp {
            port = 666 #Akka server port number
            hostname = 0.0.0.0 #Bind to all local network interfaces
            public-hostname = 192.168.0.29 #Expose public IP to enable correct routing of public messages.

        }
    }
}

Client:客户:

akka {  
    actor {
        provider = remote
    }
    remote {
        dot-netty.tcp {
            port = 0 #Tell Akka that this is a client connection/use random port.
            hostname = 192.168.0.29 #Tell Akka.NET which remote instance to connect to
        }
    }
}

Unfortunately, while I am able to successfully connect to the chat server locally, no matter how I configure my Hocon I cannot seem to get the remote instance to bind to my server actor located on the machine 192.168.0.29 .不幸的是,虽然我能够在本地成功连接到聊天服务器,但无论我如何配置我的 Hocon,我似乎都无法将远程实例绑定到位于机器192.168.0.29上的服务器角色。

The specific error message that I receive我收到的具体错误信息

[ERROR][27/11/2019 4:58:36 PM][Thread 0004][Akka.Remote.Transport.DotNetty.TcpTransport] Failed to bind to 192.168.0.29:0; shutting down DotNetty transport.
Cause: System.Net.Sockets.SocketException (10049): The requested address is not valid in its context
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)

This error message suggests to me that there is no available socket that Akka.NET can access.此错误消息向我表明没有 Akka.NET 可以访问的可用套接字。

Ironically enough, some time ago I asked a very similar question which at the time helped me resolve my connectivity issues but I never used Akka.NET till recently again.具有讽刺意味的是,前段时间我问了一个非常相似的问题,当时它帮助我解决了连接问题,但直到最近我才再次使用 Akka.NET。

I note that both machines have their firewalls turned off and can successfully ping each other, I have also played around with all various combinations of settings.我注意到两台机器都关闭了防火墙并且可以成功地相互 ping 通,我还尝试了各种不同的设置组合。

The original source code to the Akka.NET server/client application is located here , my current version of it is here . Akka.NET 服务器/客户端应用程序的原始源代码位于此处,我的当前版本位于此处

Could anyone provide any insight into what I might be doing wrong and how I can improve my debugging of Akka.NET remote connections?谁能提供有关我可能做错了什么以及如何改进 Akka.NET 远程连接调试的任何见解? For example is there a way that I can verify that the Actor system on server 192.168.0.29 is accessible from 192.168.0.52 externally?例如有一种方法,我可以验证服务器上的演员系统192.168.0.29是从访问192.168.0.52外部?

Haha, and literally 5 minutes after posting my question I was finally able to determine the solution (although its not ideal).哈哈,在发布我的问题 5 分钟后,我终于能够确定解决方案(尽管它并不理想)。

The solution was the realisation that when you instantiate the ActorSystem on the client application you are NOT actually connecting the local actor system to the remote system BUT rather creating a local instance of an actor system which itself is listening on a random port.解决方案是意识到当您在客户端应用程序上实例化ActorSystem时,您实际上并不是将本地 Actor 系统连接到远程系统,而是创建了一个 Actor 系统的本地实例,该实例本身正在侦听随机端口。

The remote connection itself occurs when you create an ActorSelection() reference.创建ActorSelection()引用时会发生远程连接本身。

So all I needed to do was change my client hocon from所以我需要做的就是改变我的客户 hocon

hostname = 192.168.0.29

TO

hostname = 192.168.0.52

However this creates one final (albeit rather small) problem.然而,这会产生一个最终的(尽管相当小)问题。 I now need a different hocon file for an instance running locally vs an instance running remotely.对于本地运行的实例和远程运行的实例,我现在需要一个不同的 hocon 文件。 Admittedly this could probably be addressed through code....诚然,这可能可以通过代码解决....

I'd be happy to mark as the solution someone who might be able to propose something that addresses this issue.我很乐意将可能能够提出解决此问题的建议的人标记为解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM