Updated client with more specific details when it cannot connect.

This commit is contained in:
nathan 2017-09-26 12:26:02 +02:00
parent 891d96f716
commit 891f8ac25d
3 changed files with 12 additions and 10 deletions

View File

@ -136,7 +136,7 @@ class Client<C extends Connection> extends EndPointClient<C> implements Connecti
if (options.localChannelName != null && options.tcpPort < 0 && options.udpPort < 0 && options.udtPort < 0) {
// no networked bootstraps. LOCAL connection only
Bootstrap localBootstrap = new Bootstrap();
this.bootstraps.add(new BootstrapWrapper("LOCAL", -1, localBootstrap));
this.bootstraps.add(new BootstrapWrapper("LOCAL", options.localChannelName, -1, localBootstrap));
EventLoopGroup localBoss = new DefaultEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(threadName + "-LOCAL",
threadGroup));
@ -159,7 +159,7 @@ class Client<C extends Connection> extends EndPointClient<C> implements Connecti
if (options.tcpPort > 0) {
Bootstrap tcpBootstrap = new Bootstrap();
this.bootstraps.add(new BootstrapWrapper("TCP", options.tcpPort, tcpBootstrap));
this.bootstraps.add(new BootstrapWrapper("TCP", options.host, options.tcpPort, tcpBootstrap));
if (isAndroid) {
// android ONLY supports OIO (not NIO)
@ -189,7 +189,7 @@ class Client<C extends Connection> extends EndPointClient<C> implements Connecti
if (options.udpPort > 0) {
Bootstrap udpBootstrap = new Bootstrap();
this.bootstraps.add(new BootstrapWrapper("UDP", options.udpPort, udpBootstrap));
this.bootstraps.add(new BootstrapWrapper("UDP", options.host, options.udpPort, udpBootstrap));
if (isAndroid) {
// android ONLY supports OIO (not NIO)
@ -237,7 +237,7 @@ class Client<C extends Connection> extends EndPointClient<C> implements Connecti
if (udtAvailable) {
// all of this must be proxied to another class, so THIS class doesn't have unmet dependencies.
Bootstrap udtBootstrap = new Bootstrap();
this.bootstraps.add(new BootstrapWrapper("UDT", options.udtPort, udtBootstrap));
this.bootstraps.add(new BootstrapWrapper("UDT", options.host, options.udtPort, udtBootstrap));
EventLoopGroup udtBoss = UdtEndpointProxy.getWorker(DEFAULT_THREAD_POOL_SIZE, threadName, threadGroup);

View File

@ -21,11 +21,13 @@ public
class BootstrapWrapper {
public final String type;
public final Bootstrap bootstrap;
public final String address;
public final int port;
public
BootstrapWrapper(String type, int port, Bootstrap bootstrap) {
BootstrapWrapper(String type, String address, int port, Bootstrap bootstrap) {
this.type = type;
this.address = address;
this.port = port;
this.bootstrap = bootstrap;
}
@ -33,6 +35,6 @@ class BootstrapWrapper {
@Override
public
String toString() {
return "BootstrapWrapper [type=" + this.type + ", port=" + this.port + "]";
return "BootstrapWrapper{" + "type='" + type + '\'' + ", address='" + address + '\'' + ", port=" + port + '}';
}
}

View File

@ -86,16 +86,16 @@ class EndPointClient<C extends Connection> extends EndPoint<C> implements Runnab
future.await();
} catch (Exception e) {
String errorMessage = stopWithErrorMessage(logger2,
"Could not connect to the " + bootstrapWrapper.type + " server on port: " +
bootstrapWrapper.port,
"Could not connect to the " + bootstrapWrapper.type + " server at " +
bootstrapWrapper.address + " on port: " + bootstrapWrapper.port,
e);
throw new IllegalArgumentException(errorMessage);
}
if (!future.isSuccess()) {
String errorMessage = stopWithErrorMessage(logger2,
"Could not connect to the " + bootstrapWrapper.type + " server on port: " +
bootstrapWrapper.port,
"Could not connect to the " + bootstrapWrapper.type + " server at " +
bootstrapWrapper.address + " on port: " + bootstrapWrapper.port,
future.cause());
throw new IllegalArgumentException(errorMessage);
}