colyseus / proxy

🔀⚔ Proxy and Service Discovery for Colyseus 0.10 ~ 0.14 (Not recommended on 0.15+)
https://docs.colyseus.io/scalability/
MIT License
37 stars 25 forks source link

seat reservation expired when using proxy with more than 3 instances randomly #30

Open naive17 opened 2 years ago

naive17 commented 2 years ago

Hi. I'm opening this issue because when i use pm2 and use more than 2/3 instances the server throws

Error: seat reservation expired.
0|colyseus-app  |     at WebSocketServer.onConnection (/Users/user/Documents/GitHub/dverso/multiplayer_server/node_modules/@colyseus/ws-transport/build/WebSocketTransport.js:105:23)
0|colyseus-app  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)

It happens casually, not everytime, but the more instances i set the more frequently it pops.

here my pm2 config

/* PM2 config file */
const os = require('os');

module.exports = {
    apps : [
      /**
       * Colyseus processes
       */
      {
        name      : 'colyseus-app',
        script    : './dist/multiplayer_server/index.js',
        instances : 8,
        exec_mode : 'fork',
        port      : 3567,
        env: {
          NODE_ENV: 'development',
        },
      },
      /**
       * Proxy process
       */
      {
        name: 'proxy',
        script: './node_modules/@colyseus/proxy/bin/proxy',
        instances: 1, // os.cpus().length,
        exec_mode: 'fork',
        env: {
          PORT : 2567,
          // Required options:
          REDIS_URL: 'redis://127.0.0.1:6379/0',

          // // SSL (optional)
          // SSL_KEY: "/Users/endel/.localhost-ssl/localhost.key",
          // SSL_CERT: "/Users/endel/.localhost-ssl/localhost.crt",
        }
      }],

  };

this is my server setup code

const gameServer = new Server({
  presence: new RedisPresence({
    db : 0,
    host : "127.0.0.1",
    port : 6379,
  }),
  driver : new MongooseDriver(),
  transport: new WebSocketTransport({
  })
});
xVanTuring commented 1 year ago

Do you use matchMaker API? If you do please check out this issue on colyseus. See if it helps.