1

I have a client/server software working perfectly fine in local but I can't figure out why, it does'nt work when I set up the server on a remote aws ec2 instance. When the client tries to connect I got the following error :

    [08/03/2016 12:47:36.231] [ClientSystem1213-akka.remote.default-remote-dispatcher-6] [akka.tcp://ClientSystem1213@127.0.0.1:2555/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FSolarServerSystem%4052.59.106.25%3A2552-0/endpointWriter] AssociationError [akka.tcp://ClientSystem1213@127.0.0.1:2555] -> [akka.tcp://SolarServerSystem@52.59.106.25:2552]: Error [Association failed with [akka.tcp://SolarServerSystem@52.59.106.25:2552]] [
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://SolarServerSystem@52.59.106.25:2552]
Caused by: akka.remote.transport.netty.NettyTransportExceptionNoStack: Connection refused: /52.59.106.25:2552
]

Running netstat -tnlp on the server gives the following :

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 ::ffff:127.0.0.1:2552       :::*                        LISTEN      4516/java     

The aws ec2 security group inbound and outbound are open for all trafic (all protocol - all port).

The akka conf common to client and server is

akka {

  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }

  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
      hostname = "127.0.0.1"
      send-buffer-size = 5000000b
      receive-buffer-size = 5000000b
      maximum-frame-size = 2500000b
    }

    watch-failure-detector {
      threshold = 100
      acceptable-heartbeat-pause = 20 s
    }
    transport-failure-detector {
      heartbeat-interval = 4 s
      acceptable-heartbeat-pause = 20 s
    }
  }

}

(I copy paste de failure and buffer part from Amazon AWS EC2 ports: connection refused)

The server only part of the conf is :

include "common"

akka {
  remote.netty.tcp.port = 2552
}

The client part is :

include "common"
include "javafx-swing-dispatch"

akka {
  remote.netty.tcp.port = 2555
  remote {
    log-config-on-start = on
    log-sent-messages = on
    log-received-messages = on
  }
}

javafx-swing-dispatch.conf being :

javafx-dispatcher {
  type = "Dispatcher"
  executor = "akka.dispatch.gui.JavaFXEventThreadExecutorServiceConfigurator"
  throughput = 1
}

swing-dispatcher {
  type = "Dispatcher"
  executor = "akka.dispatch.gui.SwingEventThreadExecutorServiceConfigurator"
  throughput = 1
}

(taken from https://gist.github.com/mucaho/8973013)

Any clues where the problem comes from ?

Community
  • 1
  • 1
lorilan
  • 311
  • 1
  • 9

2 Answers2

3

It was actually an akka configuration problem. An aws ec2 instance has a public and a private ip. The public ip is visible in the aws console on the running instance screen. The private ip is visible on the bottom part of the same screen in the description tab (and by default in the instance prompt).

These two different addresses have to be informed to the akka configuration as follow :

akka.remote.netty.tcp {
     hostname = "XX.XX.XX.XX"      # external/public (logical) hostname
     port = 2555                   # external/public (logical) port

     bind-hostname = "192.168.0.4" # internal/private (bind) hostname
     bind-port = 2555              # internal/private (bind) port
}
lorilan
  • 311
  • 1
  • 9
  • for me it worked with just the private IP. I didn't need to have the public IP part. But thanks for the question – AvinashK May 03 '20 at 03:18
1

You need to allow traffic in security configuration of ec2 instances for that you need to open ports which you are using for akka system.

Amit Yadav
  • 406
  • 2
  • 11
  • The aws ec2 security group inbound and outbound are open for all trafic (all protocol - all port). – lorilan Aug 03 '16 at 09:09
  • did the ec2 instances which are running akka system are in vpc or not? – Amit Yadav Aug 03 '16 at 09:10
  • It has a vpc id so I suppose yes – lorilan Aug 03 '16 at 09:11
  • check whether the instances are able to ping each other by running ping command from instance – Amit Yadav Aug 03 '16 at 09:18
  • there's something to dig. I've already tried with success to ping the instance from my computer but I didn't try the other way around >_< And indeed I cannot ping my computer from the instance – lorilan Aug 03 '16 at 09:24
  • false hope. My router was setup to not answer ping – lorilan Aug 03 '16 at 09:30
  • How many actor system do you have? Where is client and server situated? And do you want to send message client to server and vise versa ? If you want to request from aws to local machine you need to have static public ip and having port forwarded in your router. – Amit Yadav Aug 03 '16 at 09:30
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/118989/discussion-between-lorilan-and-amit-yadav). – lorilan Aug 03 '16 at 09:30