Merge pull request #333 from jboner/wip-1841-selectable-local-nic-√
Adding support for specifying localAddress in remote config
This commit is contained in:
commit
a0a13adf28
4 changed files with 11 additions and 1 deletions
|
|
@ -100,6 +100,10 @@ akka {
|
|||
# Default is 2552 (AKKA), use 0 if you want a random available port
|
||||
port = 2552
|
||||
|
||||
# (O) The address of a local network interface (IP Address) to bind to when creating
|
||||
# outbound connections. Set to "" or "auto" for automatic selection of local address.
|
||||
outbound-local-address = "auto"
|
||||
|
||||
# (I&O) Increase this if you want to be able to send messages with large payloads
|
||||
message-frame-size = 1 MiB
|
||||
|
||||
|
|
|
|||
|
|
@ -157,12 +157,12 @@ class ActiveRemoteClient private[akka] (
|
|||
openChannels = new DefaultDisposableChannelGroup(classOf[RemoteClient].getName)
|
||||
|
||||
executionHandler = new ExecutionHandler(netty.executor)
|
||||
|
||||
val b = new ClientBootstrap(netty.clientChannelFactory)
|
||||
b.setPipelineFactory(new ActiveRemoteClientPipelineFactory(name, b, executionHandler, remoteAddress, localAddress, this))
|
||||
b.setOption("tcpNoDelay", true)
|
||||
b.setOption("keepAlive", true)
|
||||
b.setOption("connectTimeoutMillis", settings.ConnectionTimeout.toMillis)
|
||||
settings.OutboundLocalAddress.foreach(s ⇒ b.setOption("localAddress", new InetSocketAddress(s, 0)))
|
||||
bootstrap = b
|
||||
|
||||
val remoteIP = InetAddress.getByName(remoteAddress.host.get)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ class NettySettings(config: Config, val systemName: String) {
|
|||
case value ⇒ value
|
||||
}
|
||||
|
||||
val OutboundLocalAddress: Option[String] = getString("outbound-local-address") match {
|
||||
case "auto" | "" | null ⇒ None
|
||||
case some ⇒ Some(some)
|
||||
}
|
||||
|
||||
@deprecated("WARNING: This should only be used by professionals.", "2.0")
|
||||
val PortSelector = getInt("port")
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class RemoteConfigSpec extends AkkaSpec(
|
|||
UsePassiveConnections must be(true)
|
||||
Hostname must not be "" // will be set to the local IP
|
||||
PortSelector must be(0)
|
||||
OutboundLocalAddress must be(None)
|
||||
MessageFrameSize must be(1048576)
|
||||
ConnectionTimeout must be(2 minutes)
|
||||
Backlog must be(4096)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue