Skip to content

Commit edcc54c

Browse files
ffelipelimaoclaude
andauthored
fix: downgrade MQTT QoS from 2 to 1 to prevent dropped messages (#33)
QoS 2 (exactly-once) causes receive_maximum_exceeded errors on EMQX v5 during traffic bursts, as the broker's max_awaiting_rel limit (100) gets overwhelmed. QoS 1 (at-least-once) uses a simpler 2-step handshake with no awaiting_rel state, eliminating this bottleneck entirely. For chat messages, at-least-once delivery is sufficient. Related: emqx/emqx#13399 (broker returns wrong Receive Maximum in CONNACK) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 78a754b commit edcc54c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

httpclient/httpclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (mc *HttpClient) SendMessage(ctx context.Context, topic string, payload str
105105
Topic: topic,
106106
Payload: payload,
107107
Retain: retainBool,
108-
Qos: 2,
108+
Qos: 1,
109109
ClientId: fmt.Sprintf("arkadiko-%s", uuid.NewV4().String()),
110110
}
111111

mqttclient/mqttclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (mc *MqttClient) PublishMessage(ctx context.Context, topic string, message
106106
l.Debug("Publishing message to mqtt")
107107

108108
for i := 0; i < 3; i++ { // Retry up to 3 times
109-
token := mc.MqttClient.WithContext(ctx).Publish(topic, 2, retained, message)
109+
token := mc.MqttClient.WithContext(ctx).Publish(topic, 1, retained, message)
110110
if token.WaitTimeout(mc.Timeout) {
111111
l.Debug("message published to mqtt")
112112
break

0 commit comments

Comments
 (0)