Exception while decoding PUBACK: fixed header flags must be 0 but were 8

Hi,
The server runs on wss.certigo.com:443

I can connect to this server using org.eclipse.paho.client.mqttv3.MqttClient

I want to migrate to hivemq client library.

I receive this log when connect to the server wss.certigo.com:443

2026-04-14 13:01:54.365| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.i.n.h.ssl.JdkSslContext - Default protocols (JDK): [TLSv1.3, TLSv1.2]2026-04-14 13:01:54.365| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.i.n.h.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384]

2026-04-14 13:01:54.631| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096

2026-04-14 13:01:54.631| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.io.netty.util.Recycler - -Dio.netty.recycler.ratio: 820

26-04-14 13:01:54.631| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.io.netty.util.Recycler - -Dio.netty.recycler.chunkSize: 32

2026-04-14 13:01:54.631| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.io.netty.util.Recycler - -Dio.netty.recycler.blocking: false

2026-04-14 13:01:54.631| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.io.netty.util.Recycler - -Dio.netty.recycler.batchFastThreadLocalOnly: true

2026-04-14 13:01:54.794| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.i.n.handler.ssl.SslHandler - [id: 0x0af5cccc, L:/192.168.0.194:55096 - R:wss.certigo.com/208.95.250.117:443] HANDSHAKEN: protocol:TLSv1.3 cipher suite:TLS_AES_256_GCM_SHA384

2026-04-14 13:01:54.924| ERROR | RxComputationThreadPool-1 | ironbeamAPI.xAPI - accept errorcom.hivemq.client.mqtt.mqtt3.exceptions.Mqtt3DisconnectException: Exception while decoding PUBACK: fixed header flags must be 0 but were 8

Caused by: com.hivemq.client.mqtt.exceptions.MqttDecodeException: Exception while decoding PUBACK: fixed header flags must be 0 but were 8

2026-04-14 13:01:54.930| DEBUG | com.hivemq.client.mqtt-1-1 | c.h.c.i.s.i.n.buffer.PoolThreadCache - Freed 15 thread-local buffer(s) from thread: com.hivemq.client.mqtt-1-1

mqtt cli client also cannot connect.mqtt test -h wss.certigo.com -p 443 -V 3

MQTT 3: Could not connect MQTT 3 client - Exception while decoding CONNECT: must not receive this packet type

https://www.hivemq.com/demos/websocket-client/ can connect to wss.certigo.com:443 and returns a relevant error

Connect failed: AMQJS0006E Bad Connack return code:2 Connection Refused: identifier rejected.

This is an expected behavior using the default ClientID

How can I connect to wss.certigo.com:443 using hivemq client library?

Regards,

Hello Boris,

Thanks for reaching out on our HiveMQ Community Forum.

You’re currently connecting to a WebSocket MQTT endpoint with a plain TCP MQTT client configuration, which is why you see decode errors like:

  • Exception while decoding PUBACK: fixed header flags must be 0 but were 8
  • Exception while decoding CONNECT: must not receive this packet type
    These symptoms are observed when MQTT decoders see WebSocket frames (e.g. 0x88 close frame) instead of raw MQTT packets.
    The HiveMQ Websocket Client in the browser works because it uses MQTT over WebSockets, and the broker then correctly returns a CONNACK with return code 2 (identifier rejected), which is a valid MQTT 3.1.1 response for the default client ID.

To connect with the HiveMQ Java client, you must:

  • Use WebSockets, not plain TCP.
  • Match SSL on/off to whatever works in the HiveMQ Websocket Client (SSL toggle).
  • Provide a valid client ID that the server accepts (non-empty, within allowed length, pattern, etc.).
  • (Optional but often required) Use the correct WebSocket path (commonly /mqtt, but use whatever the Websocket Client is using).

Below is a working template for MQTT 3 over WebSocket using the HiveMQ client:

import com.hivemq.client.mqtt.MqttClient;
import com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient;

Mqtt3AsyncClient client = MqttClient.builder()
        .useMqttVersion3()
        .identifier("YourValidClientIdHere") // must be accepted by the server
        .serverHost("wss.certigo.com")
        .serverPort(443)
        // Use SSL or not based on what works in the browser Websocket client
        .sslWithDefaultConfig()              // keep this if the browser uses "SSL" checked; remove if it does not
        .webSocketConfig()
            .serverPath("/mqtt")             // adjust to the actual WS path if different
            .subprotocol("mqtt")             // typical MQTT-over-WebSocket subprotocol
            .applyWebSocketConfig()
        .buildAsync();

// Then connect
client.connectWith()
        .cleanSession(true)
        .keepAlive(30)
        .send()
        .whenComplete((ack, throwable) -> {
            if (throwable != null) {
                throwable.printStackTrace();
            } else {
                System.out.println("Connected with CONNACK: " + ack);
            }
        });

Regards,
Gil

1 Like

Gil,
Your answer is perfect!
Thank you for your assistance!
Regards,