I am trying to connect to an AWS MQTT broker/server using the Hive MQ client library for Android Studio (v1.3.0) with an AWS pre-signed URL.
implementation("com.hivemq:hivemq-mqtt-client:1.3.0")
implementation(platform("com.hivemq:hivemq-mqtt-client-websocket:1.3.0"))
The parameters I am using are shown below with the sensitive information removed:
host: xxx.amazonaws.com
path: /mqtt?X-Amz-Algorithm=xxx&X-Amz-Credential=xxx&X-Amz-Date=xxx&X-Amz-SignedHeaders=host&X-Amz-Signature=xxx
This is my latest attempt to connect:
MqttClient.builder()
.identifier(UUID.randomUUID().toString())
.serverHost(host)
.webSocketConfig()
.serverPath(path)
.applyWebSocketConfig()
.sslWithDefaultConfig()
.useMqttVersion3()
.build()
But when connecting, I get the error:
com.hivemq.client.mqtt.exceptions.ConnectionFailedException: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 426 Upgrade Required