[英]Websockets and Ec2 instance
I'm using NodeJS with express to create a Websocket application with WS on EC2(Ubuntu). 我正在使用带有Express的NodeJS在EC2(Ubuntu)上用WS创建一个Websocket应用程序。 I have the following code:
我有以下代码:
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');
});
Also, I added a "custom tcp rule" to the port 8090 and anywhere(0.0.0.0/0) 另外,我在端口8090和其他任何位置(0.0.0.0/0)添加了“自定义tcp规则”
After I run: wscat --connect http://myipaddress:8090 运行后:wscat --connect http:// myipaddress:8090
I got: error: Error: connect ECONNREFUSED myipaddress:8090 我得到:错误:错误:连接ECONNREFUSED myipaddress:8090
Am I forgetting something in Ec2 Configuration or code? 我是否忘记了Ec2配置或代码中的某些内容?
Greetings 问候
Looks like you are trying to connect using the HTTP protocol. 看起来您正在尝试使用HTTP协议进行连接。 Try running
wscat --connect ws://myipaddress:8090
. 尝试运行
wscat --connect ws://myipaddress:8090
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.