如何在Node-RED中公开Web Socket?

时间:2015-12-26 08:44:32

标签: http websocket get node-red

我们正致力于项目,我们的目标是通过浏览器显示实时传感器数据。我们在Raspberry Pi上运行了真正的 AM2302温度传感器。温度传感器以 Node-RED 发布数据和节点,订阅由Raspberry Pi上的温度传感器发布的数据。现在,在Node-RED中接收数据后,我们希望使用 websocket (输出节点)公开该数据。现在我们将 http (使用 GET 方法的输入节点)连接到先前创建的websocket(输出节点)以接收数据值,并使用调试节点显示。但问题是,它不会向调试控制台显示任何数据,也不会显示任何错误。我们应该做什么 ?我们错过了什么吗? Node-RED节点的代码如下所示(采用json格式)。

[{"id":"e9e5dd7a.161a2","type":"websocket- 
listener","z":"","path":"/ws/temperatureValue","wholemsg":"false"},
{"id":"5b8e213a.a471e","type":"mqtt-
 broker","z":"98791dce.6786e","broker":"test.mosquitto.org","port":"1883","client
 id":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15"
,"cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayl
 oad":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},
 {"id":"61aceb43.9e5314","type":"debug","z":"98791dce.6786e","name":"","active":t
rue,"console":"false","complete":"false","x":712,"y":280,"wires":[]},
{"id":"b3cf17f1.4c30e8","type":"mqtt         
in","z":"98791dce.6786e","name":"Temperature Sensor 
    Publisher","topic":"sensorMeasurement","broker":"5b8e213a.a471e","x":215,"y":245
,"wires":[["f81d74ae.07e288"]]},{"id":"f81d74ae.07e288","type":"websocket 
 out","z":"98791dce.6786e","name":"","server":"e9e5dd7a.161a2","client":"","x":47
2,"y":193,"wires":[]},{"id":"d2181548.2de7e8","type":"http 
in","z":"98791dce.6786e","name":"","url":"/temperatureValue","method":"get","swa
ggerDoc":"","x":432,"y":321,"wires":[["61aceb43.9e5314"]]}]

0 个答案:

没有答案