1
votes

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://[email protected]:2555/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FSolarServerSystem%4052.59.106.25%3A2552-0/endpointWriter] AssociationError [akka.tcp://[email protected]:2555] -> [akka.tcp://[email protected]:2552]: Error [Association failed with [akka.tcp://[email protected]:2552]] [
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://[email protected]: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 ?

2

2 Answers

3
votes

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
}
1
votes

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.