Hive MQ “Invalid handshake response getStatus: 426 Upgrade Required” connecting to AWS

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

Hello. Is there is any solution for this problem? I got the same error with the version 1.3.3

Hi @Hiben ,

If you are still experiencing the issue, please feel free to share your project (repository) along with the following details:

  1. Steps to build and execute the project.
  2. Steps to test the scenario you described.

Reproducing the error on our end is essential for troubleshooting it effectively. This will help us provide a more accurate and timely solution to your problem.

Thank you!

Best regards,
Dasha from the HiveMQ Team