mercredi 22 avril 2015

Network access denied to external node.js socket

I have two servers running on Amazon's EC2. One is a standard web server running LAMP (this is behind an elastic load balancer), the other a Node.js server with Express and socket.io installed. On that Node server I have my server.js file (this file is automatically loaded on server start).

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

server.listen(8080); 

io.on('connection', function (socket) { 
    socket.on('join', function() {
        console.log('joined');
    }
}

On the LAMP server, clients connect to this external server by:

<script src="http://ift.tt/1Abvuox"></script>

var socket = io.connect('http://URL_HERE:8080');
socket.on('connect', function() {
    socket.emit('join', room_id);
});

The problem, though, is that console spits out ERR_NETWORK_ACCESS_DENIED continuously, suggesting that access to that port is blocked. However, the inbound rules for the Node server are as follows:

Custom TCP Rule -- TCP -- 8080 -- 0.0.0.0/0 (Anywhere)
HTTP            -- TCP -- 80   -- My IP
HTTPS           -- TCP -- 443  -- My IP

I have tried all sorts by more or less completely opening the inbound ports, but to no avail. It may be worth nothing as well that the only way for people to access the client script (the LAMP server) is through a load balancer - you cannot directly access the LAMP server. The load balancers inbound rules are as follows:

Custom TCP Rule -- TCP -- 8080 -- 0.0.0.0/0 (Anywhere)
HTTP            -- TCP -- 80   -- 0.0.0.0/0 (Anywhere)
HTTPS           -- TCP -- 443  -- 0.0.0.0/0 (Anywhere)

And the LAMP server's rules:

Custom TCP Rule -- TCP -- 8080 -- sg-elb_id
HTTP            -- TCP -- 80   -- sg-elb_id
HTTPS           -- TCP -- 443  -- sg-elb_id
... other irrelevant rules (SHH, MYSQL, ...)

Has anyone any idea why I'd be getting an access denied error? The Node server isn't behind the load balancer - it's in effect completely external to the process. All of the security groups are not restricted in regards to outbound rules.




Aucun commentaire:

Enregistrer un commentaire