[英]Websockets and Ec2 instance
我正在使用帶有Express的NodeJS在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協議進行連接。 嘗試運行wscat --connect ws://myipaddress:8090
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.