[{"data":1,"prerenderedAt":221},["ShallowReactive",2],{"node-red-\u002Fnode-red\u002Fcore-nodes\u002Fwebsocket":3},{"id":4,"title":5,"body":6,"description":197,"extension":214,"meta":215,"navigation":216,"path":217,"seo":218,"stem":219,"__hash__":220},"nodeRed\u002Fnode-red\u002Fcore-nodes\u002Fwebsocket.md","Node-RED - WebSocket Node",{"type":7,"value":8,"toc":196},"minimark",[9,14,19,23,28,31,49,53,56,68,72,76,79,83,99,103,114,118,121,124,128,131,134,138,141,144,149,153],[10,11,13],"h1",{"id":12},"websocket","WebSocket",[15,16,18],"h2",{"id":17},"what-are-websocket-nodes-used-for-in-node-red","What are WebSocket nodes used for in Node-RED",[20,21,22],"p",{},"Node-RED provides two WebSocket nodes that serve distinct purposes and can operate in two modes.",[24,25,27],"h3",{"id":26},"listen-on","Listen On",[20,29,30],{},"In this mode, Node-RED functions as a WebSocket server, enabling remote clients to establish connections.",[32,33,34,43],"ul",{},[35,36,37,38,42],"li",{},"The ",[39,40,41],"code",{},"WebSocket-in"," node is responsible for receiving messages sent from remote clients.",[35,44,37,45,48],{},[39,46,47],{},"WebSocket-out"," node facilitates the flow to send messages either to a specific connected client or to broadcast messages to all connected clients.",[24,50,52],{"id":51},"connect-to","Connect To",[20,54,55],{},"In this mode, Node-RED acts as a client, establishing connections with remote WebSocket servers.",[32,57,58,63],{},[35,59,37,60,62],{},[39,61,41],{}," node receives messages sent from the remote WebSocket server to Node-RED.",[35,64,37,65,67],{},[39,66,47],{}," node allows the flow to send messages to the remote server.",[15,69,71],{"id":70},"websocket-node-configuration","WebSocket node configuration",[24,73,75],{"id":74},"path","Path",[20,77,78],{},"When you use the WebSocket node in \"Listen on\" mode, you'll have to specify the path or endpoint to which remote clients will establish a connection.",[24,80,82],{"id":81},"sendreceive","Send\u002FReceive",[32,84,85,96],{},[35,86,87,88,91,92,95],{},"Payload: This option sends or receives only the ",[39,89,90],{},"msg.payload"," as data over the WebSocket connection. It excludes any additional ",[39,93,94],{},"msg"," properties.",[35,97,98],{},"Entire Message: When enabled, this option allows the entire message object, including payload, and other properties to be sent or received as a JSON formatted string.",[24,100,102],{"id":101},"url","URL",[20,104,105,106,109,110,113],{},"When you use the WebSocket node in \"Connect to\" mode, you'll have to specify the connection URL that should use ",[39,107,108],{},"ws:\u002F\u002F"," or ",[39,111,112],{},"wss:\u002F\u002F"," scheme and point to an existing WebSocket listener.",[24,115,117],{"id":116},"subprotocol","Subprotocol",[20,119,120],{},"This option allows you to specify a particular WebSocket subprotocol to use during the connection handshake.",[20,122,123],{},"For example, if a WebSocket server requires the use of the \"mqtt\" subprotocol, you would configure the WebSocket node's \"Subprotocol\" option to \"mqtt\" to ensure that the WebSocket handshake includes the MQTT protocol, enabling proper communication between Node-RED and the WebSocket server.",[24,125,127],{"id":126},"send-heartbeat","Send heartbeat",[20,129,130],{},"Enabling this option allows specifying the time interval in seconds for sending periodic ping messages from the client to the server to maintain the connection. The server responds with a pong message to confirm the connection status.",[20,132,133],{},"This helps prevent the connection from being closed due to inactivity or network issues.",[15,135,137],{"id":136},"examples","Examples",[20,139,140],{},"Simple Echo test",[20,142,143],{},"This shows both modes, with one set acting as a WebSocket Echo Server\nand the other connecting to that server and sending and receiving messages.",[145,146],"render-flow",{":height":147,"flow":148},"200","W3siaWQiOiI0MzI5NGJlNzM4Yjc2OTlhIiwidHlwZSI6InRhYiIsImxhYmVsIjoiV2ViU29ja2V0cyIsImRpc2FibGVkIjpmYWxzZSwiaW5mbyI6IiIsImVudiI6W119LHsiaWQiOiJlNzg4ZGJjNDQ0MjhmNmI3IiwidHlwZSI6IndlYnNvY2tldCBpbiIsInoiOiI0MzI5NGJlNzM4Yjc2OTlhIiwibmFtZSI6IiIsInNlcnZlciI6IiIsImNsaWVudCI6IjRkYjc4ZWI2NTNkNmQ1MGQiLCJ4IjoyOTAsInkiOjI0MCwid2lyZXMiOltbImQ4NmJhZjkzNzk1ZGJiMmQiXV19LHsiaWQiOiI4YzcwMjk3MWIwMjkyZjliIiwidHlw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jE2NjBiNGRhNDZkYjIyYWQiLCJ0eXBlIjoid2Vic29ja2V0IG91dCIsInoiOiI0MzI5NGJlNzM4Yjc2OTlhIiwibmFtZSI6IiIsInNlcnZlciI6IjU0MmY3NTFlMTUzMzdjNDYiLCJjbGllbnQiOiIiLCJ4Ijo1NjAsInkiOjMyMCwid2lyZXMiOltdfSx7ImlkIjoiNGRiNzhlYjY1M2Q2ZDUwZCIsInR5cGUiOiJ3ZWJzb2NrZXQtY2xpZW50IiwicGF0aCI6IndzOi8vbG9jYWxob3N0OjE4ODAvd3MvZWNobyIsInRscyI6IiIsIndob2xlbXNnIjoiZmFsc2UiLCJoYiI6IjAiLCJzdWJwcm90b2NvbCI6IiJ9LHsiaWQiOiI1NDJmNzUxZTE1MzM3YzQ2IiwidHlwZSI6IndlYnNvY2tldC1saXN0ZW5lciIsInBhdGgiOiIvd3MvZWNobyIsIndob2xlbXNnIjoiZmFsc2UifV0=",[15,150,152],{"id":151},"node-documentation","Node Documentation",[154,155,158,161,162,161,168,161,171,161,180,161,183,161,190,161,193],"div",{"className":156},[157],"core-node-doc",[20,159,160],{},"WebSocket input node."," ",[20,163,164,165,167],{},"By default, the data received from the WebSocket will be in ",[39,166,90],{},".\nThe socket can be configured to expect a properly formed JSON string, in which\ncase it will parse the JSON and send on the resulting object as the entire message.",[20,169,170],{},"WebSocket out node.",[20,172,173,174,176,177,179],{},"By default, ",[39,175,90],{}," will be sent over the WebSocket. The socket\ncan be configured to encode the entire ",[39,178,94],{}," object as a JSON string and send that\nover the WebSocket.",[20,181,182],{},"If the message arriving at this node started at a WebSocket In node, the message\nwill be sent back to the client that triggered the flow. Otherwise, the message\nwill be broadcast to all connected clients.",[20,184,185,186,189],{},"If you want to broadcast a message that started at a WebSocket In node, you\nshould delete the ",[39,187,188],{},"msg._session"," property within the flow.",[20,191,192],{},"This configuration node creates a WebSocket Server endpoint using the specified path.",[20,194,195],{},"This configuration node connects a WebSocket client to the specified URL.",{"title":197,"searchDepth":198,"depth":198,"links":199},"",2,[200,205,212,213],{"id":17,"depth":198,"text":18,"children":201},[202,204],{"id":26,"depth":203,"text":27},3,{"id":51,"depth":203,"text":52},{"id":70,"depth":198,"text":71,"children":206},[207,208,209,210,211],{"id":74,"depth":203,"text":75},{"id":81,"depth":203,"text":82},{"id":101,"depth":203,"text":102},{"id":116,"depth":203,"text":117},{"id":126,"depth":203,"text":127},{"id":136,"depth":198,"text":137},{"id":151,"depth":198,"text":152},"md",{},true,"\u002Fnode-red\u002Fcore-nodes\u002Fwebsocket",{"title":5,"description":197},"node-red\u002Fcore-nodes\u002Fwebsocket","_4FOxLgiNPejFQy8qD32uea_MenkpTxuHgJhQ2PIgJk",1780070556378]