How to get topic of mqtt client in websocket server

て烟熏妆下的殇ゞ 提交于 2019-12-13 07:19:26

问题


I am trying to get topic of mqtt client, i searched in google, i couldn't find right one.

for example, from mqtt client, publish one message,consider server topic is 'topicOfServer' and client topic is 'topicOfClient'.

client.publish('topicOfServer','hi server');

server will get 'hi server' message. but how do server knows that message came from which client ex: 'topicOfClient'


回答1:


You seam to be confusing a couple of things here

  1. Topics are just "addresses" that any MQTT client can send a message to, they are not owned in any way by any client.
  2. There is no way to determine which MQTT client published any message from another MQTT client unless the sender encodes that information somewhere in the message payload.


来源:https://stackoverflow.com/questions/42668325/how-to-get-topic-of-mqtt-client-in-websocket-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!