【发布时间】:2016-02-24 18:12:17
【问题描述】:
我正在尝试从我的 python 程序中获取信息并在网页上实时更新。
我正在尝试使用 node-red 并通过网络套接字进行通信。
我的python程序如下:
#!/usr/bin/python
import time
import websocket
ws = websocket.WebSocket();
ws.connect("ws://localhost:1880/ws/example")
count = 0;
while(count < 50):
print "Sending 'Hello, World'..."
ws.send("Hello, World")
print "Sent"
time.sleep(5)
count = count + 1
ws.close()
使用 Node-red 我已将流程设置如下:
但是,当我同时运行它们时,我的 python 程序说它正在发送消息,但是节点红色控制台为 msg 值返回 null。
【问题讨论】:
-
ws/example 中有什么?
-
你使用什么包提供“websocket”?
标签: python node.js websocket node-red