magistrala icon indicating copy to clipboard operation
magistrala copied to clipboard

Fix Nats Failed to Unmarshal MQTT Data

Open rodneyosodo opened this issue 2 years ago • 5 comments

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

rodneyosodo avatar Oct 25 '23 06:10 rodneyosodo

When I debug I saw, that NATS resend a raw message from the MQTT client (not message.proto)

nintran52 avatar Feb 17 '24 14:02 nintran52

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

nintran52 avatar Feb 17 '24 15:02 nintran52

@dborovcanin and @arvindh123 please take a look at this issue

drasko avatar Feb 17 '24 15:02 drasko

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

nintran52 avatar Feb 19 '24 09:02 nintran52

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).

dborovcanin avatar Feb 19 '24 09:02 dborovcanin

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.

dborovcanin avatar May 15 '24 10:05 dborovcanin