Seat reservation expired when many servers using the same redis


I'm using Colyseus for managing multiplayer logic in my one-week game challenge. It worked like a charm when I deployed my first project, but after adding another one I've observed errors sometimes when a user tries to create a new room.

colyseus:errors Error: seat reservation expired.

The funny thing is that I've seen room creation log message in game server A when I was really creating the room in game server B. So I guess something is getting crazy when I use redis presence in both servers.

Am I right? Could redis presence be the source of the problem when two servers use the same redis server? Is there a way, like setting a namespace or similar, to share a redis among many servers?

Hi @sgmonda, welcome! 👋

From my understanding you have two different games - each one deployed using a single process.

By using the same Redis database, they'll try to communicate with each other. There are two options you can take:

  1. Do not use RedisPresence at all. If you have both games on a single process, Redis is not going to help you there.
  2. Use a different Redis database for each game (redis://your-redis-host/0, redis://your-redis-host/1, etc)

Hope this helps! Cheers!

Wow. It's exactly my situation. I just fixed it by using @endel suggestion.
Thank you

For the moment I'm using a single process, but I may scale these games in the future. I'll stop using redis presence now but it looks like a temporal fix. Thanks @endel !
Is there any plan to support different games with a single redis database? It would be very useful when using more than a process per game. I mean something like choosing a namespace in the redis presence configuration:

const gameServer = new Server({
  server: http.createServer(app),
  presence: new RedisPresence({ namespace: 'my-game-one' }),  // <--

That namespace could be used like a preffix in any redis-key used.

Hi @sgmonda, not sure I get your question :)

The same Redis instance can have multiple "databases". It doens't need to be a different Redis host. The last segment of the Redis URI is the database number. You can use different numbers for each game, in the same Redis instance.

Hi @endel

I got the same issue regarding "seat reservation expired"
In my case, I use pm2 to create server instances and redbird proxy for load balancing.
I failed to connect to 1 of the server instances, but it's doing okay with the other instance. (for testing, i create 2 server instances) My purpose is to make those servers connected on the same process.
My question is, can redis be used for multiple servers of the same game? Is there any solution I can do to fix this issue?

Hope to hear your feedback about this.

Hi @volkfalcon, are you using plain redbird, or @colyseus/proxy?

The custom proxy ( listens to Redis as well to be able to forward the connections to the right Node through the processId available in the URL.

Beware that node-http-proxy seem to have memory leaks ( Redbird uses it as a dependency, and now @colyseus/proxy is using node-http-proxy directly (it used to be redbird in the past)

Colyseus needs a better option for scalability besides using this proxy.

Hi again @endel,

I was using only plain redbird, and seems like each server can't handle the same process at all. I tried to change the code a bit, following some of your proxy logic but ended up getting the same result. In the end, the proxy should know which host and port to handle the proccess.

Before using redbird, I have also tried @colyseus/proxy but I thought it's not working since it always responded as timeout. After your suggestion, I tried your custom proxy again, and I just found out that the host caught by your proxy is hosted by ubuntu environment, while I tried the url from windows. Things work like a charm right after I change the host on your proxy code to (of course for testing purpose only).

Thanks for the information about memory leaks, but seems like I got no other choice than your custom proxy for now. Yes, colyseus really needs a better option. It helps a lot in multiplayer game development. Hope to hear the good news soon.

Thank you for your kind response, @endel

@endel I didn't know about specifying multiple database using the URI. Thanks!