mirror of https://github.com/grpc/grpc-java.git
netty: fix local socket bind
This commit is contained in:
parent
7675ce2d47
commit
52d6a6e680
|
|
@ -220,11 +220,6 @@ class NettyClientTransport implements ConnectionClientTransport {
|
||||||
// so it is safe to pass the key-value pair to b.option().
|
// so it is safe to pass the key-value pair to b.option().
|
||||||
b.option((ChannelOption<Object>) entry.getKey(), entry.getValue());
|
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
|
* We don't use a ChannelInitializer in the client bootstrap because its "initChannel" method
|
||||||
|
|
@ -273,7 +268,13 @@ class NettyClientTransport implements ConnectionClientTransport {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Start the connection operation to the server.
|
// 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) {
|
if (keepAliveManager != null) {
|
||||||
keepAliveManager.onTransportStarted();
|
keepAliveManager.onTransportStarted();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue