Skip to content

mqtt-kafka: some QoS 1 subscribers get SUBACK but never receive messages when they subscribe before publishing starts; some first get DISCONNECT 131 #3290

Closed

Description

@ankitk-me

Describe the bug

When MQTT subscribers connect before any publisher, some QoS 1 subscribers get CONNACK 0 and a SUBACK but never receive a message. A QoS 0 subscriber on the same topic, connected at the same time, receives every message (about 190).

Some of these subscribers are disconnected by Zilla with DISCONNECT reason 131 (Implementation specific error) within 2 s of connecting, before any publisher has connected. The client reconnects, gets CONNACK 0 and SUBACK again, and still receives nothing. Others connect once and simply receive nothing. Zilla logs nothing besides BINDING_MQTT_CLIENT_CONNECTED.

The problem is intermittent. On Zilla 2.7.0 it happened in 9 of 18 fresh-stack runs: 13 stalled QoS 1 subscribers in all, 10 of them connected twice. One more subscriber got DISCONNECT 131 but did receive messages after reconnecting. Clients rejected at connect with "Session taken over" (#3101) are not counted here.

To Reproduce

  1. Start examples/mqtt.kafka.proxy from scratch (docker compose down -v && docker compose up -d). Wait for ENGINE_STARTED.
  2. Subscribe first: 10 topics, with one QoS 1 and one QoS 0 subscriber on each:
    NET=zilla-mqtt-kafka-proxy_default; R="v$(date +%s)"
    docker run -d --name subs --network $NET -e R=$R eclipse-mosquitto:2.0 sh -c '
      for i in $(seq 1 10); do
        mosquitto_sub -d -h zilla.examples.dev -p 7183 -V mqttv5 -i $R-s1-$i -q 1 -t device/$R/$i -W 30 > /tmp/q1-$i 2>&1 &
        mosquitto_sub -d -h zilla.examples.dev -p 7183 -V mqttv5 -i $R-s0-$i -q 0 -t device/$R/$i -W 30 > /tmp/q0-$i 2>&1 &
      done; wait
      for i in $(seq 1 10); do for q in 1 0; do f=/tmp/q$q-$i
        echo "topic $i qos$q: received=$(grep -c "received PUBLISH" $f) connack=$(grep -o "CONNACK ([0-9]*)" $f | sed "s/[^0-9]//g" | tr "\n" " ")$(grep -o "DISCONNECT ([0-9]*)" $f | tr "\n" " ")"
      done; done; sleep 600'
  3. Five seconds later, start publishing: 10 QoS 1 publishers, one per topic, 10 msg/s each for 20 s:
    sleep 5
    docker run -d --name pubs --network $NET emqx/emqtt-bench:latest pub -h zilla.examples.dev -p 7183 \
      -c 10 -R 100 --prefix "$R-p-" -t "device/$R/%i" -q 1 -I 100 -s 16
    sleep 20; docker rm -f pubs; sleep 10; docker logs subs; docker rm -f subs
  4. Look for a qos1 line with connack=0 and received=0 while the qos0 line for the same topic shows about 190. If none shows up, repeat from step 1.

Expected behavior

Every QoS 1 subscriber that got CONNACK 0 receives as many messages as the QoS 0 subscriber on the same topic, and Zilla doesn't disconnect it.

Actual behavior

Client output for one stalled subscriber (mosquitto_sub -d):

Client v1794836316-s1-8 sending CONNECT
Client v1794836316-s1-8 received CONNACK (0)
Client v1794836316-s1-8 sending SUBSCRIBE (Mid: 1, Topic: device/v1794836316/8, QoS: 1, Options: 0x00)
Client v1794836316-s1-8 received SUBACK
Subscribed (mid: 1): 1
Received DISCONNECT (131)
Client v1794836316-s1-8 sending CONNECT
Client v1794836316-s1-8 received CONNACK (0)
Client v1794836316-s1-8 sending SUBSCRIBE (Mid: 2, Topic: device/v1794836316/8, QoS: 1, Options: 0x00)
Client v1794836316-s1-8 received SUBACK
Subscribed (mid: 2): 1
Client v1794836316-s1-8 sending DISCONNECT

It received 0 messages, while the QoS 0 subscriber on device/v1794836316/8 received 192. Zilla logged the two BINDING_MQTT_CLIENT_CONNECTED events for this client 1.75 s apart, before the publishers started, and nothing else. Where we measured it (8 subscribers that connected twice), the two connects were 1.3–1.8 s apart.

Across 15 fresh-stack runs on Zilla 2.7.0:

Runs Runs with a stall Stalled QoS 1 subscribers Connected twice (DISCONNECT, then reconnect)
3 with the exact commands above 2 2 2
10 with earlier versions of these commands (same clients and rates; only the output differed) 2 3 3
5 with our test script (same clients and rates) 5 8 5
Total 9 13 10

Every other QoS 1 subscriber that got CONNACK 0 received 186–194 messages, including the one that recovered after DISCONNECT 131 (189). No errors in the Kafka log.

Notes

  • The DISCONNECT comes before any message is published, so this looks like the subscription failing during setup. One candidate is the per-client consumer group (zilla:<namespace>-north_mqtt_kafka_mapping-<clientId>) failing to join or sync, rather than a delivery stalling midway.
  • It also happened with a single QoS 1 subscriber and no other subscribers: CONNACK 0, SUBACK, then 0 of 20 messages published 4 s later, while all 20 reached Kafka.
  • Reproduced with mosquitto_sub subscribers, so this is not specific to the load tool.

Environment

  • Zilla ghcr.io/aklivity/zilla:2.7.0 start -e, unmodified examples/mqtt.kafka.proxy zilla.yaml
  • Kafka apache/kafka:4.1.1, single node
  • Docker Desktop (Engine 29.8.1) on an Apple Silicon Mac, 10 CPUs and 8 GB for Docker
  • Clients: eclipse-mosquitto:2.0 (MQTT 5), emqx/emqtt-bench:latest

Activity

  1. added
    bug
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions