Is is possible to limit concurrent conference room a authenticated user can setup

I want to limit the number of conference room an authenticated user can run concurrently at any time so that a user can not setup and run many conferences at the same time. Is it possible?

As authenticated users has the same jid, this is possible by implementing a custom prosody module.

It will be a limit for concurrent sessions on one shard. So if you have multiple shards you will need a central service of tracking those.

Here is how to access all current sessions
Also this is an example that can be useful

I managed to look at the example and got the session limiter to work. However, I am wondering where do we add the code to display proper message to user. I saw customized message can be displayed based on xmpp event but do we add and trigger the event in the LUA script?

For example when max people is reached (the mod_muc_max_occupants module) hits lib-jitsi-meet here: and that triggers the chain of events

Hi - would you be able to share your script with the community? Thanks!

Sure, below is my simple code. However, there is still a problem I am facing that prevent this code to work properly when I use secure domain with anonymous users.

I have a different post regarding the problem I am facing, but nobody replied yet :slightly_frowning_face: Secure domain login issue

When I enable secure domain with anonymous user, I see strange behavior (I am not sure whether it is normal behavior). I have an user logging into the secure domain with password. However, from the jocofo.log I saw the logged on user was straight away kicked out and replaced by an anonymous user in the same session. If I use the code below, I got a guest user ID instead of the user’s ID. And when the user (which I think it is the guest user) hang up the session, the session is still being held in the server. And other users are still able to join the room as guest user without authenticating. I have no way to restrict the concurrent session by using the code below.

Can anyone help?

local split_jid = require “util.jid”.split;
local it = require “util.iterators”;

local MAX_USERSESSIONS = module:get_option_number(“muc_max_usersessions”, -1);

local function check_for_max_usersessions(event)
local room, origin, stanza =, event.origin, event.stanza;

local actor = stanza.attr.from;
local user, domain, res = split_jid(stanza.attr.from);
local session = event.origin;

if user == nil then

local count = 0;
local u;
for key, value in pairs(prosody.full_sessions) do
u = tostring(value[“username”]);
if u:lower() ~= “focus” then
if u == user then
module:log(“info”, “Found same user " … user … " in a room”);
count = count + 1;
module:log(“info”, "Total count for user " … user … " is " … count);

if count > MAX_USERSESSIONS then
module:log(“info”, "User " … u … " attempts to create session over limit of " … MAX_USERSESSIONS);
origin.send(st.error_reply(stanza, “cancel”, “service-unavailable”));
return true;

module:hook(“muc-occupant-pre-join”, check_for_max_usersessions, 10);

Thank you for sharing first of all. :slight_smile:

I’ll give it a try on my end and let you know the behavior. So, your code is called muc_max_usersessions.lua and enabled in the Virtual Host? Anything else to it.

Thanks again.

Just enable it in the virtual host and may be set up the muc_max_usersessions variable and that’s it.