2017-02-23 412 views
1

以下命令顯示發佈到與正則表達式匹配但不是確切主題本身的主題的所有消息。如何在訂閱時使mosquitto_sub打印主題和消息#

mosquitto_sub -h localhost -u user -P pass -t 'devices/#' 
{"value":"50"} 
{"value":"45"} 

例如上面的JSON消息發表主題設備/ 1234 /傳感器/ 46364 /但我想不出什麼辦法來打印的主題,以及使用mosquitto_sub。

回答

2

使用-v選項

mosquitto_sub -h localhost -u user -P pass -v -t 'devices/#' 

從手冊頁:

-v, --verbose 
     Print received messages verbosely. With this argument, messages 
     will be printed as "topic payload". When this argument is not 
     given, the messages are printed as "payload".