magistrala
magistrala copied to clipboard
Fix Nats Failed to Unmarshal MQTT Data
Fix the following error
mainflux-mqtt | {"level":"warn","message":"Failed to unmarshal received message: proto: cannot parse invalid wire-format data","ts":"2023-10-25T06:44:27.506603048Z"}
A possible reason behind it is the failure to decode Payload data to MF Message
When I debug I saw, that NATS resend a raw message from the MQTT client (not message.proto)
NATS Subscribe received 2 messages, one from Mqtt (with raw format from clients) and another from NATS publisher (after converting to messaging struct)
- First message can not Unmarshal from proto and re-receive after 30s
- The messages from the retry caused the system to stall
@dborovcanin and @arvindh123 please take a look at this issue
NATS clients also receive messages from MQTT, so to fix this issue I think we need to separate MQTT Broker and NATS Message into two (don't use the same NATS) cc: @dborovcanin, @arvindh123
Hello, @nintran52,
To fix this issue I think we need to separate MQTT Broker and NATS Message
This is true. However, we have separated it in v0.14.0 by reverting the VerneMQ to be the default MQTT broker. There are other reasons for that, such as that NATS does not support the full range of MQTT 3.1 features and it would limit our MQTT support, as well as support for protocols that are built on top of MQTT (such as Sparkplug).
Closing the issue since it was caused by using the same instance of NATS for Proto messages and MQTT messages. We opted for using VerneMQ due to better MQTT support.