参考: nodejs搭建简易服务器,模拟webSocket 后台主动推送消息给浏览器进行接收 server模拟服务端,运行命令: node app.js client模拟客户端,运行:直接浏览器打开,点击 "开启服务器推送" 按钮