我有一个客户端/服务器软件在本地工作得非常好,但我无法弄清楚为什么,当我在远程aws ec2实例上设置服务器时,它确实有效。当客户端尝试连接时,我收到以下错误:
[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
]
在服务器上运行netstat -tnlp将提供以下内容:
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
aws ec2安全组的入站和出站对所有交通都是开放的(所有协议 - 所有端口)。
客户端和服务器共有的akka conf是
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
}
}
}
(我从Amazon AWS EC2 ports: connection refused复制粘贴失败和缓冲部分)
服务器中只有conf的一部分是:
include "common"
akka {
remote.netty.tcp.port = 2552
}
客户端部分是:
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正在:
javafx-dispatcher {
type = "Dispatcher"
executor = "akka.dispatch.gui.JavaFXEventThreadExecutorServiceConfigurator"
throughput = 1
}
swing-dispatcher {
type = "Dispatcher"
executor = "akka.dispatch.gui.SwingEventThreadExecutorServiceConfigurator"
throughput = 1
}
(摘自https://gist.github.com/mucaho/8973013)
问题来自的任何线索?
答案 0 :(得分:2)
这实际上是一个akka配置问题。 aws ec2实例具有公共和私有ip。公共IP在运行实例屏幕上的aws控制台中可见。私有IP在描述选项卡的同一屏幕的底部可见(默认情况下在实例提示中)。
这两个不同的地址必须通知akka配置如下:
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 :(得分:1)
您需要允许ec2实例的安全配置中的流量,因为您需要打开用于akka系统的端口。