Close room properly (prosody custom module)

Apologies if this sounds rude, but I think so many codes flying around make a new user/developer on this thread even more confused.

Not sure if there is a way to consolidate all the coddes in one place that shows what all needs to be done from start to finish in one-shot. And pls dont forget to include/metion the path of the file that needs to be edited.

I for example have an issue (right now). I opened a room few weeks ago and when I run the live room report, I can see that room is still open with 3 participant in it. So I joined that room as a new user and I can still join it and the report shows 4 users in the room, which means that the room is live.

I have used all the codes presented here in different folders and files but the session/users/room does not get terminated/killed/disconnected.

So either I am editing a wrong file (@ wrong path) or my setup/infrastructure is different or the given code does not work after the recent update (which I doubt).

If someone is willing to help me only, I am happy to consolidate everything and present it as a document that can be used by others.

Just so you know,I am behind a natted firewall and right now I am running an open server, which means no one needs to register or authenticate anything. (Can this be the root cause of the issue)?
Everything else so far is working perfectly fine… its just that I want to terminate the room once the moderator leaves.

Many Thanks,

1 Like

Is it possible that we can pass the. Duration value in the jwt token e.g for 1hr and acoording to that when Jitsi room reaches at time limit room will be destroyed by

If yes please guide me how to achieve this

Thank you

Hi @plokta,

Where should i put these settings:

close_room_delay = 30;  -- seconds until conference is destroyed after last moderator left
focus_user_jid = "focus@meet.jitsi";  -- JID of your focus/jicofo user. Should be same as in 'admins' array

Should it be in /etc/prosody/conf.d/mydomain.cfg.lua?


the time restricted conference

Hi everyone.

I tried to implement this in my self-host Jitsi but it doesn’t work. I created a file called “mod_close_rooms.lua” in this path:


And here, I put this code (is the same code above from @plotka ):

local async = require "util.async";
local timer = require "util.timer";

local delay = module:get_option_number("close_room_delay", 30);
local focus_jid = module:get_option_string("focus_user_jid", "");

module:log("info","module loaded");

local async_destroy = async.runner(function (event)
        local leaver = event.occupant.bare_jid;
        local room =;
    local wait, done = async.waiter();

    timer.add_task(delay, function ()
    wait(); -- Wait here until done() is called

    local mods = room:each_affiliation("owner");
    for mod in mods do
        module:log("debug", "administrador encontrado: %s", tostring(mod));
            if mod ~= leaver and mod ~= focus_jid then
            -- there is still a moderator in this room, dont kick participants
            module:log("info", "el administrador sigue presente en la sala: %s", mod);
    module:log("info", "room destroyed.");

module:hook("muc-occupant-left", function(event)
    local barejid = event.occupant.bare_jid;
    local role =;
    module:log("debug", "el usuario %s ha dejado la sala: %s", role, barejid);
    if role == "owner" and barejid ~= "" then

So, I modified the file:


To put the changes that I see above and the conference component it has been like this:

Component "" "muc"
    storage = "memory"
    modules_enabled = {
        -- "token_verification";
    admins = { "" }
    muc_room_locking = false
    muc_room_default_public_jids = true
    close_room_delay = 10;  -- seconds until conference is destroyed after last moderator left
    focus_user_jid = "";  -- JID of your focus/jicofo user. Should be same as in 'admins' array

I restarted the prosody service using:

sudo systemctl restart prosody

Finally, I started a meeting in a laptop and gives me administrator roles (correct) and then in other laptop I join the meeting. And, when I hang up (leave) the administrator, the other user stills in the meeting, don’t close the room automatically after 10 seconds.

So, where can be the mistake?


I used the same code as you did, but it says async file missing. How to solve this, Please help.

To check if the prosody muc is closed, open a conference with three participants and make the admin leave. After 10 seconds, the remaining two participants should be disconnected from each other, i.e., while they remain in the conference view, they cannot see or hear each other anymore.

The example prosody module destroys the muc room, so the conference is killed. However, as mentioned in the original post above, you would need to implement a hangup or a redirect in the frontend code if you want the participants to leave the conference view.

I did exactly same as what @Ferran_Munoz didi but still not working!

module:log(“debug”, “el usuario %s ha dejado la sala: %s”, role, barejid);
if role == “owner” and barejid ~= “” then

do I need to change with from the module?

does it work with JWT token authentication? do we need to define something in the JWT payload?

Yes, you need to set the config option focus_user_jid to the exact same value of the focus user from the admins array. This may also be the same issue @Ferran_Munoz has had when trying this code.

It should work with JWT authentication as well, since the focus user is always present in a conference regardless of the authentication method used. However, I did not try it myself with JWT auth enabled.

This is not necessary but could probably be done if you want to. As has been discussed in the beginning of this thread, you could try to check event.origin.auth_token to see if the leaving user is authenticated via JWT instead of checking for the owner role

So I have to do the following steps:

  1. Save the above code as /usr/share/jitsi-meet/prosody-plugins/mod_quit.lua

local async = require “util.async”;

  1. Paste “quit”; in /etc/prosody/conf.avail/my.domain.cfg.lua
    Is this ok?

Hi @plokta : It seems that the custom prosody modules work without JWT token.

I have faced one issue here. I used below code to kickout participant when moderator ends the call. I have written this in conference.js when user left.
if(user._role === ‘moderator’) {
let participants = APP.conference.listMembers();
participants.forEach(participant => {, participant));
document.location.href="/"; // i add this for reloading page, since it make user stuck in hidden room after kicked
It works when participant logged in from browsers. But moderator unable to kickou when participant logged in android app. Please help.

As far as I know, the android app doesn’t load much of the javascript from the server and mobile app behavior and available configuration options deviate considerably from the web app. However, this has nothing to do with prosody nor JWT auth.

Hi @plokta , Thanks for your response. I am getting one issue after implementing the custom module you have suggested. Also I have enabled moderator. Room destroy and participant kick out are working for android app browser. But the problem is, once participant got kicked out and moderator left the room and again rejoin the room, the participant’s video got muted, though video is enabled in the android app side. Also the moderator credentials are not asking when moderator join the room. Also in my self hosted jitsi-meet jibri is enabled. Server side recording is also not working, showing some message like recording service not available, but jibri service is enabled and working. Can you give some light on this please.
Thanks in advanced.

I think that you mean really ‘the moderator recreates the room’, since it’s supposed to be destroyed. In this case I’d say that’s a defect of the Android client that has not properly finished after the room has been destroyed. The prosody module can kick out clients, but if the client is bugged it can’t do much more. And it could be a bug in the Jitsi source code you have used to build your app, or a bug of your own design. I have seen disturbing things with some versions of the official Jitsi Android client when meetings stop.

Thanks @gpatel-fr for your response. Could you please help how can I resolve this or anyone in this community. I did not find how to resolve this, probably it is because of the jitsi source code. Please help. Thanks,

if you can reproduce this problem reliably with current Jitsi-meet Android client, create a Github issue on the jitsi-meet android project (with appropriate detail)
If iyou have a custom client and only this client displays the problem, you will have to debug it yourself.

Thanks @gpatel-fr for your response.

you can try this module.