1

Context

I'm trying to create a load balancer with AWS Copilot that runs socket.io instances.

Locally and in an HTTP environment, I can successfully connect to the socket instance via the load balancer (ws://{id}.elb.{region}.amazonaws.com:8080/socket.io/?EIO=4&transport=websocket).

Architecture Diagram

Problem

When I'm in the HTTPS context and try to connect, it fails and I get the error message Error: Websocket error with no real error message or status code (wss://{id}.elb.{region}.amazonaws.com:8080/socket.io/?EIO=4&transport=websocket).

With ws:// everything works and in wss:// it does not work.

Code Snippets

AWS Copilot manifest.yml

name: websocket-service
type: Load Balanced Web Service

http:
  path: '/'
  healthcheck: '/health'

nlb:
  port: 8080/tcp

Server

import {Server} from 'https'; // I use HTTPS here

// ...
        this._io = socketIo(server); 
// ...

Client

// ... 
    const client = socketClient(url, {
        transports: ['websocket']
    });
// ...

AWS Console

EC2 -> Load Balancing -> Load Balancers -> {target} -> Listeners Load Balancer Listeners

Dock
  • 103
  • 7

0 Answers0