Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. ahtashamabbasse
  3. Posts
  • Profile
  • More
    • Continue chat with ahtashamabbasse
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Posts made by ahtashamabbasse

Fail-over and load balancing colyseus Testing

We have successfully configured Colyseus with two nodes in fork mode using PM2, installed latest REDIS (4.0.9), and also added RedisPresence code. It seems to be working.

0_1556547267268_485a5ccc-cb66-47f0-9f99-031e1ad03393-image.png

Snippet to configure Redis

const gameServer = new Server({
    server: createServer(app),
    presence: new RedisPresence(),
});

pm2 configuration

const os = require('os');
module.exports = {
    apps: [{
        port: 2567,
        name: "suicidePoker",
        script: "./index.ts", // your entrypoint file
        watch: true,           // optional
        instances: 2,
        exec_mode: 'fork',         // IMPORTANT: do not use cluster mode.
        exec_interpreter : "ts-node",
        env: {
            DEBUG: "colyseus:errors",
            NODE_ENV: "production",
        }
    }]
}

We now need to test the failover and load balancing.

Will are assuming that all room states will be saved in Redis transparently, without us having to anything.

We then connected to one node (2567 port) and then added two players using different browsers. We saw them appear in the same in the room, using the monitor. We saved some room state e.g. this.player.coins=5 etc etc. Please check screenshot. You can see that on both nodes, we can see the same states. So far, so good. We can see state replication.

We had also created an API that crashes the server.

Something like this:

app.get('/api/ping', function (req, res) {
     setTimeout(function () {
      throw new Error("Let's crash the server for Testing");
         }, 10000);
    res.status(200).json({'status':''})

}); 

Colyseus Monitor

0_1556547379420_bb34f240-c8c6-4524-b506-4d56bf6b326e-image.png

After room state data was saved, we crashed the 2567 node. After a few seconds we checked the Colyseus monitor on both ports i.e. 2567 and 2568 there is no room, and all state is gone.
What is happening here?
Video demo

posted in Questions & Help • 29 Apr 2019, 14:36
RE: How to get rooms count and clients count that connect to server

@endel thanks, we're done with it server scalability. Next step is redis.

posted in Questions & Help • 29 Apr 2019, 06:36
RE: How to get rooms count and clients count that connect to server

@endel link of Server and Clusterserver is broken.

posted in Questions & Help • 27 Apr 2019, 08:10
RE: Mazebattles.com: Race to solve generated mazes

There should be feature something like Maze Generator. Because in your game will be played in a different group of ages.

posted in Showcase • 27 Apr 2019, 07:50
RE: onLeave timeout

@DinhNguyen and @rscata I think you both are looking for rejoin the game. Below snippet will solve your problem. For more details: Rejoin Link.

async onLeave (client, consented: boolean) {
  // flag client as inactive for other users
  this.state.players[client.sessionId].connected = false;

  try {
    if (consented) {
        throw new Error("consented leave");
    }

    // allow disconnected client to rejoin into this room until 20 seconds
    await this.allowReconnection(client, 20);

    // client returned! let's re-activate it.
    this.state.players[client.sessionId].connected = true;

  } catch (e) {

    // 20 seconds expired. let's remove the client.
    delete this.state.players[client.sessionId];
  }
}
posted in Questions & Help • 28 Mar 2019, 11:37
RE: How to overcome requesting "locked"Timeout setting: 200ms issue

Nope, we are not using RedisPresence right now. It's happened more than 10 times.

posted in Questions & Help • 28 Feb 2019, 06:27
How to overcome requesting "locked"Timeout setting: 200ms issue

Hi @endel , After pushing the game to live server we have noticed that following issue. is there a way to increase request timeout time?

remote room (rdmNyA6vy) timed out, requesting "locked" Timeout setting: 200ms
Error: remote room (rdmNyA6vy) timed out, requesting "locked"Timeout setting: 200ms
    at Timeout.setTimeout (/home/ubuntu/suicidePoker/node_modules/colyseus/lib/MatchMaker.js:158:32)
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)
    at Timer.listOnTimeout (timers.js:277:5)

Thanks

posted in Questions & Help • 27 Feb 2019, 09:48
RE: Could we start Colyseus app with npm package forever?

did you resolve this issue?

posted in Questions & Help • 21 Feb 2019, 12:29
RE: Use PM2, typescript for Heroku

We are also facing same issue, other projects is working fine but colyseus isn't working fine. Looking forward to seeing your assistance @endel

"scripts": {
    "start": "ts-node index.ts",
    "bundle-colyseus-client": "browserify ./node_modules/colyseus.js/lib/index.js -s Colyseus -o static/colyseus.js",
    "build": "npm run bundle-colyseus-client",
    "heroku-postbuild": "npm run build"
  }, 

Please check the below link too.
https://stackoverflow.com/questions/54767053/nodejs-server-doesnt-start-with-pm2/54786719#54786719

posted in General Discussion • 21 Feb 2019, 12:21
RE: Array handling in colyseus.

thanks for your reply it means alot for us. We will try it.

posted in Questions & Help • 21 Feb 2019, 12:19
Array handling in colyseus.

How to get array in unity from colyseus state?

0_1549602223569_image.png

posted in Questions & Help • 8 Feb 2019, 05:04
Could we start Colyseus app with npm package forever?

We are facing some issue while using npm package forever Trying to restart the server automatically after crash.
Below is the code.
Before
"start":"nodemon --watch '**/*.ts' --exec ts-node index.ts""
After
"start": "forever start --minUptime 1000 --spinSleepTime 10000 ./index.ts",

"scripts": {
    "start": "forever start --minUptime 1000 --spinSleepTime 10000 ./index.ts",
    "bundle-colyseus-client": "browserify ./node_modules/colyseus.js/lib/index.js -s Colyseus -o static/colyseus.js",
    "build": "npm run bundle-colyseus-client",
    "heroku-postbuild": "npm run build"
  }

Server Stop after processing file

0_1548224034861_ea265c02-00d7-47cd-ba25-d2258773e124-image.png

posted in Questions & Help • 23 Jan 2019, 06:05
RE: How to create new project from scratch??

You can start working from it Sample Project easily just modify it as per your requirements.

posted in Questions & Help • 11 Jan 2019, 07:54

© 2023 Endel Dreyer