1

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

1
  • You are trying to connect with http://myipaddress:8090 but it should be ws://myipaddress:8090 Commented Jan 2, 2016 at 5:20

1 Answer 1

2

Looks like you are trying to connect using the HTTP protocol. Try running wscat --connect ws://myipaddress:8090.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.