我有两个系统: system 1运行akka和HAProxy,system 2运行向akka发出请求的REST组件。
Akka运行在系统1上的端口4241上。当没有HAProxy时,system 2能够连接到System 1。在系统1上安装HAProxy之后,从system 2到system 1的请求出现错误,日志如下:
到达akka.tcp://akkaSystemName@Server1IP:42431个入站地址是akka.tcp://akkaSystemName@Server1IP://akkaSystemName@Server1IP:4241
HAProxy运行在42431。
HAProxy配置如下:
listen akka_tcp :42431
mode tcp
option tcplog
balance leastconn
server test1 Server1IP:4241 check
server test2 Server1IP:4241 checkakka的配置如下:
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
netty.tcp {
hostname = "Server1IP"
port = 4241
transport-protocol = tcp
# Sets the send buffer size of the Sockets,
# set to 0b for platform default
send-buffer-size = 52428800b
# Sets the receive buffer size of the Sockets,
# set to 0b for platform default
receive-buffer-size = 52428800b
maximum-frame-size = 52428800b
}
}如有任何建议,将不胜感激。
发布于 2015-09-21 12:35:59
最新答案:
可能Akka远程处理不应该与负载均衡器一起工作。看看它的文档的这一部分
Akka远程处理是一个以对等方式连接参与者系统的通信模块,它是Akka集群的基础。远程处理的设计由两个(相关的)设计决策驱动: 1.所涉及系统之间的通信是对称的:如果系统A可以连接到系统B,那么系统B也必须能够独立地连接到系统A。 2.就连接模式而言,通信系统的作用是对称的:没有只接受连接的系统,也没有只启动连接的系统。 这些决定的结果是,不可能安全地创建具有预定义角色(违反假设2)和使用涉及网络地址转换或负载平衡器(违反假设1)的纯客户端服务器设置。 对于客户端服务器设置,最好使用HTTP或Akka I/O。
对于您的情况,在system 1上使用Akka HTTP或Akka I/O来接受和回答来自system 2的请求似乎是合理的。
旧答案:
您必须在Akka配置中设置bind-port属性。以下是Akka文件的引文
# Use this setting to bind a network interface to a different port
# than remoting protocol expects messages at. This may be used
# when running akka nodes in a separated networks (under NATs or docker containers).
# Use 0 if you want a random available port. Examples:
#
# akka.remote.netty.tcp.port = 2552
# akka.remote.netty.tcp.bind-port = 2553
# Network interface will be bound to the 2553 port, but remoting protocol will
# expect messages sent to port 2552.对于你的港口来说应该是这样的:
port = 42431
bind-port = 4241https://stackoverflow.com/questions/32678139
复制相似问题