Skip to content

Commit c5337b1

Browse files
graebmbgklika
andauthored
add ability to read RpcServer port bound when port auto selected by OS (#280)
Co-authored-by: Vitaly Khalmansky <[email protected]>
1 parent 75a10c0 commit c5337b1

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ mkdir sdk-workspace
8080
cd sdk-workspace
8181
# Clone the CRT repository
8282
# (Use the latest version of the CRT here instead of "v0.16.4")
83-
git clone --branch v0.16.4 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
83+
git clone --branch v0.16.12 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
8484
cd aws-crt-java
8585
# Compile and install the CRT
8686
mvn install -Dmaven.test.skip=true
@@ -102,7 +102,7 @@ mkdir sdk-workspace
102102
cd sdk-workspace
103103
# Clone the CRT repository
104104
# (Use the latest version of the CRT here instead of "v0.16.4")
105-
git clone --branch v0.16.4 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
105+
git clone --branch v0.16.12 --recurse-submodules https://github.com/awslabs/aws-crt-java.git
106106
# Compile and install the CRT for Android
107107
cd aws-crt-java/android
108108
./gradlew connectedCheck # optional, will run the unit tests on any connected devices/emulators
@@ -126,7 +126,7 @@ repositories {
126126
}
127127
128128
dependencies {
129-
implementation 'software.amazon.awssdk.crt:android:0.16.4'
129+
implementation 'software.amazon.awssdk.crt:android:0.16.12'
130130
}
131131
```
132132

android/iotdevicesdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ repositories {
9191
}
9292

9393
dependencies {
94-
api 'software.amazon.awssdk.crt:aws-crt-android:0.16.4'
94+
api 'software.amazon.awssdk.crt:aws-crt-android:0.16.12'
9595
implementation 'org.slf4j:slf4j-api:1.7.30'
9696
implementation 'com.google.code.gson:gson:2.9.0'
9797
implementation 'androidx.appcompat:appcompat:1.1.0'

sdk/greengrass/event-stream-rpc-server/src/main/java/software/amazon/awssdk/eventstreamrpc/RpcServer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class RpcServer implements AutoCloseable {
3232
private ServerTlsContext tlsContext;
3333
private ServerListener listener;
3434
private AtomicBoolean serverRunning;
35+
private int boundPort = -1;
3536

3637
public RpcServer(EventLoopGroup eventLoopGroup, SocketOptions socketOptions, TlsContextOptions tlsContextOptions, String hostname, int port, EventStreamRPCServiceHandler serviceHandler) {
3738
this.eventLoopGroup = eventLoopGroup;
@@ -72,9 +73,21 @@ public void onConnectionShutdown(ServerConnection serverConnection, int errorCod
7273
LOGGER.info("Server connection closed code [" + CRT.awsErrorString(errorCode) + "]: " + serverConnection.getResourceLogDescription());
7374
}
7475
});
76+
77+
boundPort = listener.getBoundPort();
78+
7579
LOGGER.info("IpcServer started...");
7680
}
7781

82+
/**
83+
* Get port bound to.
84+
*
85+
* @return port number that service is bound to.
86+
*/
87+
public int getBoundPort() {
88+
return boundPort;
89+
}
90+
7891
/**
7992
* Stops running server and allows the caller to wait on a CompletableFuture
8093
*/

sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>software.amazon.awssdk.crt</groupId>
4444
<artifactId>aws-crt</artifactId>
45-
<version>0.16.9</version>
45+
<version>0.16.12</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>org.slf4j</groupId>

0 commit comments

Comments
 (0)