简体   繁体   中英

Setting up SocketIO server on AWS EC2

I've got a problem to run the server with socketIO module on AWS EC2 server. My current code:

const port     = process.env.PORT || 8080;
var server = require('http').Server();
var io = require('socket.io')(server);
const socketioHandler = require(backPath + 'functions/socketioHandler');
socketioHandler.ioConnections(io);

server.listen(port, 'ec2-IP_XXX.compute-1.amazonaws.com');

And the URI that I'm using to connect client to the server:

ec2-IP_XXX.compute-1.amazonaws.com:8080

It seams that for some reason the client cannot find the server.

This is the issue regarding the Security Group.

Security Groups has an Inbound rule, which is actually related to Port block or which all port should be open for the outside world.

So you have to open port 8080 for outside world.

在此处输入图片说明

在此处输入图片说明

So just add port 8080 (through edit option) in your inbound rules

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM