Reputation: 53
I'm using NodeJS with express to create a Websocket application with WS on EC2(Ubuntu). 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)
After I run: wscat --connect http://myipaddress:8090
I got: error: Error: connect ECONNREFUSED myipaddress:8090
Am I forgetting something in Ec2 Configuration or code?
Greetings
Upvotes: 1
Views: 1997
Reputation: 322
Looks like you are trying to connect using the HTTP protocol. Try running wscat --connect ws://myipaddress:8090
.
Upvotes: 2