Node-Red 和 Web 套接字 [英] Node-Red and Web socket

查看:47
本文介绍了Node-Red 和 Web 套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Windows 环境中处理 node-red 的 websockets(我已经成功地在 Linux 上尝试).

I'm trying to works on node-red's websockets on windows environment (I've successfully try on Linux).

我有如下图所示的简单应用

I've simple apps like pictured below

它在控制台上不起作用:

and it's doesn't work output on console :

17 Feb 09:07:04 - [error] [websocket out:c87881cc.37878] TypeError: Cannot read property 'wholemsg' of null

节点红色 json :

node-red json :

[{
    "id": "50702139.8696e",
    "type": "websocket-client",
    "z": "f00fcb86.2de8f8",
    "path": "/press",
    "wholemsg": "false"
}, {
    "id": "c87881cc.37878",
    "type": "websocket out",
    "z": "f00fcb86.2de8f8",
    "name": "",
    "server": "",
    "client": "50702139.8696e",
    "x": 361,
    "y": 66,
    "wires": []
}, {
    "id": "c99314fe.366ce8",
    "type": "inject",
    "z": "f00fcb86.2de8f8",
    "name": "",
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "repeat": "",
    "crontab": "",
    "once": false,
    "x": 163,
    "y": 67,
    "wires": [["c87881cc.37878"]]
}, {
    "id": "12f91072.ed06f",
    "type": "websocket in",
    "z": "f00fcb86.2de8f8",
    "name": "",
    "server": "",
    "client": "50702139.8696e",
    "x": 162,
    "y": 147,
    "wires": [["62f0f292.9d0f0c"]]
}, {
    "id": "62f0f292.9d0f0c",
    "type": "debug",
    "z": "f00fcb86.2de8f8",
    "name": "",
    "active": true,
    "console": "true",
    "complete": "true",
    "x": 344,
    "y": 147,
    "wires": []
}]

有人有什么想法吗?

推荐答案

看起来整个 json 就是一个数组.在数组的第一个元素中有一个对象,其中包含整个消息.地址为 node-red json[0].wholemsg 其中node-red json"是您保存消息的变量名.

It looks like the json as a whole is an array. In the first element of the array there is an object and within that is the wholemsg. Address as node-red json[0].wholemsg where "node-red json" is your variable name holding the message.

这篇关于Node-Red 和 Web 套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆