Navigation

    Colyseus
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. ahtashamabbasse
    A

    ahtashamabbasse

    @ahtashamabbasse

    Chat Follow Unfollow
    6
    Reputation
    13
    Posts
    1493
    Profile views
    0
    Followers
    3
    Following
    Joined Last Online
    Age 27

    • Profile
    • More
      • Continue chat with ahtashamabbasse
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    ahtashamabbasse Follow

    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 •
    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 •
    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 •
    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 •
    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 •
    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 •
    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 •
    RE: Could we start Colyseus app with npm package forever?

    did you resolve this issue?

    posted in Questions & Help •
    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 •
    RE: Array handling in colyseus.

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

    posted in Questions & Help •