我使用Tcl MQTT API與代碼MQTT Tcl API中的錯誤?
source mqtt.tcl
proc message_callback { topic message } {
puts stderr "message on topic $topic: $message"
}
set client [mqtt new]
$client connect my-client $::addr
$client subscribe {BCDS/#} message_callback
vwait _done
運行一個簡單的用戶客戶端和正常工作與當地的券商,如。蚊子在同一個局域網上運行(至少在運行時沒有發現問題)。
但與互聯網上的經紀人,例如。 iot.eclipse.org,打印一對夫婦的消息後
message on topic BCDS/XDK/single/20:19:AB:F4:04:56/out/stream:
{"sn":"20:19:AB:F4:04:56","data":{"acc":
{"x":26,"y":32,"z":1012,"unit":"mG"},"gyro":{"x":1220,"y":-6835,"z":-
2319,"unit":"mdeg/s"},"mag":{"x":40,"y":1,"z":-4,"unit":"uT"},"light":
{"value":7466,"unit":"mLux"},"temp":
{"value":50000,"unit":"mCelsius"},"pressure":
{"value":98897,"unit":"Pascal"},"humidity":{"value":39,"unit":"%rh"}}}
message on topic BCDS/XDK/single/20:19:AB:F4:04:53/out/stream:
{"sn":"20:19:AB:F4:04:53","data":{"acc":
{"x":26,"y":32,"z":1012,"unit":"mG"},"gyro":{"x":1220,"y":-6835,"z":-
2319,"unit":"mdeg/s"},"mag":{"x":40,"y":1,"z":-4,"unit":"uT"},"light":
{"value":13617,"unit":"mLux"},"temp":
{"value":50000,"unit":"mCelsius"},"pressure":
{"value":98897,"unit":"Pascal"},"humidity":{"value":39,"unit":"%rh"}}}2ú
,BCDS/XDK/single/20:19:AB:F4:04:52
/out/strea{"sn":"20:19:AB:F4:04:52","data":{"acc":
{"x":26,"y":32,"z":1012,"unit":"mG"},"gyro":{"x":1220,"y":-6835,"z":-
2319,"unit":"mdeg/s"},"mag":{"x":40,"y":1,"z":-4,"unit":"uT"},"light":
{"value":7789,"unit":"mLux"},"temp":{"value":50000,"unit":"mCelsius"},
它在10秒內未能堆棧跟蹤
1507901608909 (::oo::Obj22_coro): can't read "msgid": no such variable
while executing
"dict set rc msgid $msgid"
(class "::mqtt" method "receive" line 35)
invoked from within
"my receive"
(class "::mqtt" method "listen" line 27)
invoked from within
"my listen"
我調試表明,該API不通過連接手柄連接消息?我對麼?有沒有人使用這個API來做任何實質性的事情?
嘗試將客戶端id my-client改爲random,以確保它不與現有客戶端衝突。 – hardillb
只有一個連接,它打印一些消息,但在10秒內失敗。修改了我原來的帖子。 –