Skip to content

Commit

Permalink
[PAN-2703] JSON-RPC api net_services should display the actual ports (P…
Browse files Browse the repository at this point in the history
…egaSysEng#1628)

Currently when json-rpc and ws services are configured with a port value of 0, the "net_services" endpoint will display their ports as "0".  A configured port of "0" actually means "choose a random port".  We need to get the actual port that those services are using displayed in the "net_services" JSON-RPC response.
  • Loading branch information
AbdelStark authored Jul 2, 2019
1 parent c23fbc8 commit ddb9196
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public void verify(final Node node) {

assertThat(InetAddresses.isUriInetAddress(result.get("ws").get("host"))).isTrue();
final int wsPort = Integer.valueOf(result.get("ws").get("port"));
// TODO: Port should not be 0-valued. Refer to PAN-2703
assertThat(NetworkUtility.isValidPort(p2pPort) || wsPort == 0).isTrue();
assertThat(NetworkUtility.isValidPort(wsPort)).isTrue();

assertThat(InetAddresses.isUriInetAddress(result.get("jsonrpc").get("host"))).isTrue();
final int jsonRpcPort = Integer.valueOf(result.get("jsonrpc").get("port"));
// TODO: Port should not be 0-valued. Refer to PAN-2703
assertThat(NetworkUtility.isValidPort(p2pPort) || jsonRpcPort == 0).isTrue();
assertThat(NetworkUtility.isValidPort(jsonRpcPort)).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void verify(final Node node) {

assertThat(InetAddresses.isUriInetAddress(result.get("jsonrpc").get("host"))).isTrue();
final int jsonrpcPort = Integer.valueOf(result.get("jsonrpc").get("port"));
// TODO: Port should not be 0-valued. Refer to PAN-2703
assertThat(NetworkUtility.isValidPort(jsonrpcPort) || jsonrpcPort == 0).isTrue();
assertThat(NetworkUtility.isValidPort(jsonrpcPort)).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public CompletableFuture<?> start() {
res -> {
if (!res.failed()) {
resultFuture.complete(null);
final int actualPort = httpServer.actualPort();
LOG.info(
"JsonRPC service started and listening on {}:{}",
config.getHost(),
httpServer.actualPort());
"JsonRPC service started and listening on {}:{}", config.getHost(), actualPort);
config.setPort(actualPort);
return;
}
httpServer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ private Handler<AsyncResult<HttpServer>> startHandler(final CompletableFuture<?>
return res -> {
if (res.succeeded()) {

final int actualPort = res.result().actualPort();
LOG.info(
"Websocket service started and listening on {}:{}",
configuration.getHost(),
res.result().actualPort());

actualPort);
configuration.setPort(actualPort);
resultFuture.complete(null);
} else {
resultFuture.completeExceptionally(res.cause());
Expand Down

0 comments on commit ddb9196

Please sign in to comment.