The presigned websocket url is something like this
wss://<host>.eu-west-1.amazonaws.com:443/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=<cred>/eu-west-1/iotdevicegateway/aws4_request&X-Amz-Date=20250814T085431Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=<signature>&X-Amz-Security-Token=<token>
And here is my code
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<Boolean> connected = connection.connect();
connected.get(); // Wait for connection to complete
I'm getting following error when I run the code
java.util.concurrent.ExecutionException: software.amazon.awssdk.crt.mqtt.MqttException: Attempt to sign an http request without credentials