Und hier ist mein Code < /p>
Code: Select all
AwsIotMqttConnectionBuilder builder = AwsIotMqttConnectionBuilder.newMtlsBuilderFromPath(null, null)
.withWebsockets(true) // Crucial for presigned URL connections
.withEndpoint(connectionUrl) // Pass the presigned URL here
.withClientId(clientId)
.withConnectionEventCallbacks(callbacks)
.withWebsocketSigningRegion("eu-west-1")
.withPort(443); // Default WebSocket port
MqttClientConnection connection = builder.build();
// Connect to AWS IoT Core
CompletableFuture connected = connection.connect();
connected.get(); // Wait for connection to complete