0

So I've been in the process of shifting from targeting an ec2 instance directly over to an application load balancer. Doing this, I've had issues connecting to my socket (it was working fine before). All my ALB requests work fine, just the socket being the issue. Here's my setup/config: My ALB config ALB config

ALB listener + rule enter image description here

My server code

var http = require('http');

var server = http.createServer(function(req, res) {
fs.readFile('./app.html', 'utf-8', function(error, content) {
    res.writeHead(200, {"Content-Type": "text/html"});
   res.end(content);
});
});
var io = require('socket.io').listen(server);
server.listen(443);

my client code (ios):

NSURL* url = [[NSURL alloc] initWithString:@"https://www.mywebsite.com:443"];

self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}];

[self.socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
    NSLog(@"socket connected");


}];

And finally the error message I'm receiving:

404 Not Found The requested URL /socket.io/ was not found on this server.

tomrondo
  • 21
  • 1
  • 5
  • The error indicates that the URL in question is `/socket.io/` but your balancer configuration says `/socket.io`. That seems significant. Perhaps the correct configuration for the balancer would be `/socket.io*`? – Michael - sqlbot Jan 03 '18 at 00:02
  • That doesn't _seem_ to be the issue. If I delete the rule I still get the same response/error. – tomrondo Jan 03 '18 at 02:19
  • Is this the only target group on the balancer, and is there only one instance in the target group? – Michael - sqlbot Jan 03 '18 at 03:35
  • there is two target groups on the load balancer -- one for regular requests and the other for the socket. There is only one instance in the target groups. – tomrondo Jan 03 '18 at 03:47
  • Review the logs on the instances. Your request appears to be arriving at the wrong one, seemingly confirmed by the fact that the error remains without the rule in place. – Michael - sqlbot Jan 03 '18 at 05:19
  • @tomrondo I know it's been quite a while, but have you ever figured this out? I'm having the same issue. – Gilson Viana Jun 15 '20 at 13:19

0 Answers0