[英]AWS EC2 client/server can't communicate via Node HTTP server
I have two AWS EC2 instanses. 我有两个AWS EC2实例。 A Server and a client Node JS app.
服务器和客户端Node JS应用程序。
Locally my code is working fine. 在本地,我的代码工作正常。 But at AWS the client simply shuts down after some time - like 30 sec - without any warning/exception (For some reason it can't find and connect to the server)
但是在AWS上,客户端只是在一段时间(例如30秒)后关闭,没有任何警告/异常(由于某种原因,它无法找到并连接到服务器)
Both AWS instances are running: Windows Server 2016 Base. 两个AWS实例都在运行:Windows Server 2016 Base。
Both AWS instance have their own sererate "AWS security group". 两个AWS实例都有其自己的复杂的“ AWS安全组”。 Just to make sure i'm not blocking any thing both security groups currently allow: "All traffic to ANY IP" - both Ingoing and Outgoing traffic.
只是为了确保我没有阻止两个安全组当前都允许的任何事情:“到任何IP的所有流量”-传入和传出流量。
Both instances run in the same "Availability zone" in AWS. 两个实例均在AWS的同一“可用区”中运行。
The server is listening at host: '0.0.0.0', port: 4080. And the client tries to connect to the server's IP at port 4080. I have tried to connect to all possible options - like: 服务器正在侦听主机:'0.0.0.0',端口:4080。客户端尝试在端口4080连接到服务器的IP。我试图连接到所有可能的选项,例如:
I can't even ping the server's IP from the client or from my own PC. 我什至无法从客户端或我自己的PC ping服务器的IP。 I can access both AWS instances fine via RDP.
我可以通过RDP很好地访问两个AWS实例。
Here is a bit of my code: 这是我的一些代码:
var server = require('http').createServer();
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({ server: server });
server.on('request', app);
server.listen(_port, '0.0.0.0', function () { console.log('SERVER STARTED! (listening on port # ' + _port + ')') });
var WebSocket = require('ws');
var _ws = new WebSocket(THE_SERVER_IP);
_ws.on('open', function open() {
...
});
_ws.on('message', function (data, flags) {
...
});
_ws.on('close', function close() {
...
});
解决方案:我向运行server.js应用程序的服务器中的Windows防火墙添加了一个自定义TCP规则-允许客户端的IP连接到端口4080。完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.