Websocket closes to 1005 when attempting to send static files and keep a socket connection

Been stuck with my webhook closing instantaneously after it has connected and unsure how to diagnose error 1005?
Project is https://fanatical-tinted-radar.glitch.me/

Trying to offer static files in /app/web/index.html, .js, .css, etc awhile also handling websockets through the same port?

Github project I’m trying to use, https://github.com/d-zone-org/d-zone/tree/master
The project usually uses nginx to host the web content instead, however, glitch only offers one port, so I figured to use express and express-ws to merge providing static files and the webhook.

var expressWs = require('express-ws')(app);
  this.wss = expressWs.getWss();
  app.listen(3000)
  app.ws('/echo', function(wss, req) {
    wss.on('connection', function(socket) {
      console.log(DateFormat(new Date(), 'm/d h:MM:ss TT'),
          `client connected to server (${wss.clients.size} total)`);
      onConnect(socket);
      socket.on('message', function(data) {
          console.log("DataReceived" + data)
          data = JSON.parse(data);
          if(data.type === 'connect') { // Connection request from client
              console.log("DataReceived CONNECT" + data)
              onJoinServer(socket, data.data);
          }
      });
      socket.on('close', function(code, desc) {
          console.log(DateFormat(new Date(),
              "h:MM:ss TT"),'client disconnected, total:', wss.clients.length, code, desc);
      });
      socket.on('error', err => console.log('Socket error:', err));
    });
    wss.on('request',(msg) => console.log("Websocket Request!:", msg))
    wss.on('listening', () => console.log('Websocket listening on port'));
    wss.on('error', err => console.log('Websocket server error:', err));
    wss.on('close', err => console.log('Websocket server closed:', err));
  })
  .use(express.static(__dirname + '/../web/'))

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.