【发布时间】:2016-01-02 13:31:16
【问题描述】:
我正在使用 NodeJS 和 express 在 EC2(Ubuntu)上创建一个带有 WS 的 Websocket 应用程序。 我有以下代码:
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({ port: 8090 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
另外,我在 8090 端口和任何地方(0.0.0.0/0)添加了一个“自定义 tcp 规则”
运行后: wscat --connect http://myipaddress:8090
我得到: 错误:错误:连接 ECONNREFUSED myipaddress:8090
我是否忘记了 Ec2 配置或代码中的某些内容?
问候
【问题讨论】:
-
您正在尝试与
http://myipaddress:8090连接,但它应该是ws://myipaddress:8090
标签: node.js amazon-web-services amazon-ec2 websocket