Skip to content

Commit

Permalink
add ability to read RpcServer port bound when port auto selected by OS (
Browse files Browse the repository at this point in the history
#280)


Co-authored-by: Vitaly Khalmansky <[email protected]>
  • Loading branch information
graebm and bgklika authored May 26, 2022
1 parent 75a10c0 commit c5337b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mkdir sdk-workspace
cd sdk-workspace
# Clone the CRT repository
# (Use the latest version of the CRT here instead of "v0.16.4")
git clone --branch v0.16.4 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
git clone --branch v0.16.12 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
cd aws-crt-java
# Compile and install the CRT
mvn install -Dmaven.test.skip=true
Expand All @@ -102,7 +102,7 @@ mkdir sdk-workspace
cd sdk-workspace
# Clone the CRT repository
# (Use the latest version of the CRT here instead of "v0.16.4")
git clone --branch v0.16.4 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
git clone --branch v0.16.12 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
# Compile and install the CRT for Android
cd aws-crt-java/android
./gradlew connectedCheck # optional, will run the unit tests on any connected devices/emulators
Expand All @@ -126,7 +126,7 @@ repositories {
}
dependencies {
implementation 'software.amazon.awssdk.crt:android:0.16.4'
implementation 'software.amazon.awssdk.crt:android:0.16.12'
}
```

Expand Down
2 changes: 1 addition & 1 deletion android/iotdevicesdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ repositories {
}

dependencies {
api 'software.amazon.awssdk.crt:aws-crt-android:0.16.4'
api 'software.amazon.awssdk.crt:aws-crt-android:0.16.12'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RpcServer implements AutoCloseable {
private ServerTlsContext tlsContext;
private ServerListener listener;
private AtomicBoolean serverRunning;
private int boundPort = -1;

public RpcServer(EventLoopGroup eventLoopGroup, SocketOptions socketOptions, TlsContextOptions tlsContextOptions, String hostname, int port, EventStreamRPCServiceHandler serviceHandler) {
this.eventLoopGroup = eventLoopGroup;
Expand Down Expand Up @@ -72,9 +73,21 @@ public void onConnectionShutdown(ServerConnection serverConnection, int errorCod
LOGGER.info("Server connection closed code [" + CRT.awsErrorString(errorCode) + "]: " + serverConnection.getResourceLogDescription());
}
});

boundPort = listener.getBoundPort();

LOGGER.info("IpcServer started...");
}

/**
* Get port bound to.
*
* @return port number that service is bound to.
*/
public int getBoundPort() {
return boundPort;
}

/**
* Stops running server and allows the caller to wait on a CompletableFuture
*/
Expand Down
2 changes: 1 addition & 1 deletion sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>software.amazon.awssdk.crt</groupId>
<artifactId>aws-crt</artifactId>
<version>0.16.9</version>
<version>0.16.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down

0 comments on commit c5337b1

Please sign in to comment.