aboutsummaryrefslogtreecommitdiff
path: root/netty
diff options
context:
space:
mode:
authorCarl Mastrangelo <notcarl@google.com>2018-10-18 15:16:43 -0700
committerGitHub <noreply@github.com>2018-10-18 15:16:43 -0700
commitbee73968c063b87007527e2f22f3489e9bb747ca (patch)
tree2f068aa8782ccd793b8c60f9ce2c12f97facc82b /netty
parente8cf3fa8eaca3abc61c066f67a94e62bdbb7322d (diff)
downloadgrpc-grpc-java-bee73968c063b87007527e2f22f3489e9bb747ca.tar.gz
netty: fix local socket bind
Diffstat (limited to 'netty')
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyClientTransport.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
index 2be71c20d..c1cc07850 100644
--- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
+++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
@@ -219,11 +219,6 @@ class NettyClientTransport implements ConnectionClientTransport {
// so it is safe to pass the key-value pair to b.option().
b.option((ChannelOption<Object>) entry.getKey(), entry.getValue());
}
- SocketAddress localAddress =
- localSocketPicker.createSocketAddress(remoteAddress, eagAttributes);
- if (localAddress != null) {
- b.localAddress(localAddress);
- }
/**
* We don't use a ChannelInitializer in the client bootstrap because its "initChannel" method
@@ -272,7 +267,13 @@ class NettyClientTransport implements ConnectionClientTransport {
}
});
// Start the connection operation to the server.
- channel.connect(remoteAddress);
+ SocketAddress localAddress =
+ localSocketPicker.createSocketAddress(remoteAddress, eagAttributes);
+ if (localAddress != null) {
+ channel.connect(remoteAddress, localAddress);
+ } else {
+ channel.connect(remoteAddress);
+ }
if (keepAliveManager != null) {
keepAliveManager.onTransportStarted();