简体   繁体   中英

Topic errors when publishing an event to MQTT

I'm using the pubsub library from an ESP8266 NodeMCU and the Arduino IDE.

https://github.com/knolleary/pubsubclient/tree/master/examples/mqtt_esp8266

My device is registered with the IBM Bluemix IoT Foundation (IoTF).

The client name I'm using is

char* myclient = "d:ORGID:Devicetype:Deviceid"; 

Where orgid is my orgID from Bluemix and the Device type and id are from the device I created and registered in the IoTF. The topic I'm posting to is by this line in my code:

client.publish("iot-2/evt/status/fmt/json", msg);

In Node-RED I have an IOT-in node looking at Device Status and using the Bluemix service for auth.

I am seeing this error when I put a debug node looking at the complete message object from the IoT-in node (note: I changed my orgid to ORGID in this debug output):

{
    "_msgid": "9f433f7b.60bcc",
    "deviceId": "InterConnect",
    "deviceType": "nodeMCU",
    "payload": {
        "Action": "Disconnect",
        "ClientAddr": "24.47.149.38",
        "ClientID": "d:ORGID:nodeMCU:InterConnect",
        "CloseCode": 276,
        "ConnectTime": "2016-02-14T18:32:19.328Z",
        "Port": 1883,
        "Protocol": "mqtt4-tcp",
        "ReadBytes": 111,
        "ReadMsg": 0,
        "Reason": "The topic is not valid.",
        "SecureConnection": false,
        "Time": "2016-02-14T18:32:19.397Z",
        "User": "use-token-auth",
        "WriteBytes": 4,
        "WriteMsg": 0
    },
    "topic": "iot-2/type/nodeMCU/id/InterConnect/mon"
}

I'm wondering how my topic got changed to what it's showing here. Any ideas?

发生这种情况是因为我的代码正在订购“ iot-2 / evt / command_id / fmt / format_string”而不是“ iot-2 / cmd / command_id / fmt / format_string”-一旦我解决了问题,一切就很好了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM