简体   繁体   English

如何处理传入的 TCP 消息并在 Node-RED 中发送响应?

[英]How to handle incoming TCP message and send a response in Node-RED?

Using Node-RED TCP socket nodes, is there any way to handle incoming messages when the flow is acting as a TCP socket server (TCP out) that sends data to connected clients?使用 Node-RED TCP 套接字节点,当流充当向连接的客户端发送数据的 TCP 套接字服务器(TCP 输出)时,有什么方法可以处理传入的消息?

The idea is to allow a "is alive?"这个想法是让一个“还活着?” method.方法。

The TCP-out node can be set to "Reply" mode which when linked to a TCP-in node in "Server" mode will accept incoming connections and allow you to reply. TCP-out 节点可以设置为“Reply”模式,当链接到“Server”模式下的 TCP-in 节点时,它将接受传入连接并允许您回复。

The following example just echo's the input back to the client.以下示例只是将输入回显给客户端。

在此处输入图像描述

[{"id":"ef432e3f1a0f275e","type":"tcp in","z":"cc3f50ef2f39f8d0","name":"","server":"server","host":"","port":"8889","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"","base64":false,"tls":"","x":270,"y":160,"wires":[["825896b40c7c96b9","d24c5bbd4d73d2af"]]},{"id":"825896b40c7c96b9","type":"debug","z":"cc3f50ef2f39f8d0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":200,"wires":[]},{"id":"d24c5bbd4d73d2af","type":"tcp out","z":"cc3f50ef2f39f8d0","name":"","host":"","port":"","beserver":"reply","base64":false,"end":false,"tls":"","x":530,"y":160,"wires":[]}]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM