-->
Page 1 of 1

Receiving empty messages with secured MQTT subscription

PostPosted: Sun Feb 14, 2016 8:19 am
by kyberpunk
I'm trying to securely connect ESP8266 to MQTT Azure Protocol Gateway broker on cloud or local computer (tried both) like this:

Code: Select allm = mqtt.Client("{deviceId}", "3600", "{iotHub}/{deviceId}", "{SASToken}")
...
m:on("message", function(conn, top, data)
  print(data) -- EMPTY string here!
end)
  ...
m:connect({IP}, 8883, 1, function(conn)
  m:subscribe("devices/{deviceId}/messages/devicebound/#", 1, function(conn)
    ...
  end)
end)


ESP connects to server and handshake is completed successfully. When I publish some data, I can read it on server properly, it is OK. I subscribe to topic without problems. When I send data in cloud-to-device message from server to ESP to subscribed topic, 'on message' event is called but data attribute passed to the function is EMPTY string.

I'm using latest NodeMCU master build based on 1.4.0 SDK and also tried dev version.

I tried following:
  • free memory up to 32kB - not help
  • captured packets with WireShark: packets contain encrypted data with some lenght, so it is not empty and packet size is less than 2kB buffer size
Can someone please advise me where could be a problem or how to debug it for more info? I would approciate any ideas. Thank you.

EDIT:
Here is debug output, nothing interesting there...
Code: Select allenter mqtt_socket_received.
MQTT_DATA: type: 3, qos: 0, msg_id: 0, pending_id: 0
enter deliver_publish.
string
userdata: 3fff3e88
devices/ESP/messages/devicebound
          <- here should be printed data
On
leave deliver_publish.
receive, queue size: 0
leave mqtt_socket_received.
enter mqtt_socket_timer.
timer, queue size: 0
keep_alive_tick: 71
leave mqtt_socket_timer.
enter mqtt_socket_received.
MQTT_DATA: type: 7, qos: 1, msg_id: 8813, pending_id: 0
receive, queue size: 0
leave mqtt_socket_received.

Re: Receiving empty messages with secured MQTT subscription

PostPosted: Mon Apr 04, 2016 2:48 pm
by jvannor
For what it's worth.. I'm having the same problem. I get the topic fully populated, but my message bodies are empty. I've tried using the subscription event as a trigger to get the message using HTTP(s)/REST, but that doesn't work either. It seems that my MQTT subscriber eats the message before I can make a call over REST to fetch it. (I was hoping that I could fall back to HTTP/REST to get message bodies and just use MQTT as a trigger.)