简体   繁体   English

在AWS EC2上设置SocketIO服务器

[英]Setting up SocketIO server on AWS EC2

I've got a problem to run the server with socketIO module on AWS EC2 server. 我在AWS EC2服务器上运行带有socketIO模块的服务器时遇到问题。 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: 以及我用来将客户端连接到服务器的URI:

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. 因此,您必须为外部世界打开端口8080。

在此处输入图片说明

在此处输入图片说明

So just add port 8080 (through edit option) in your inbound rules 因此,只需在入站规则中添加端口8080(通过编辑选项)即可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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