0

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.

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:

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.

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.

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.

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.

The original source code to the Akka.NET server/client application is located here, my current version of it is here.

Could anyone provide any insight into what I might be doing wrong and how I can improve my debugging of Akka.NET remote connections? 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?

Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54
Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243

1 Answers1

0

Haha, and literally 5 minutes after posting my question I was finally able to determine the solution (although its not ideal).

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.

The remote connection itself occurs when you create an ActorSelection() reference.

So all I needed to do was change my client hocon from

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. 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.

Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243