HowTo install and configure mod mucsize?

Background information:
Debian 10, Apache2 web server jitsi-meet installed using;

The above installed jitsi-meet, and meeting are working well. After the installation, I found the file /usr/lib/prosody/modules/mod_muc_size.lua and would like to enable it.

Questions: Are there instructions for:

  1. how to configure (and what to install) to get mod_muc_size.lua working?

  2. documentation on how to use this module, for example how to access the room size information? Is it by https://jitsi.mydomain.com and/or by command line using curl?

If not, could someone please explain how to access the room size information provided by mod_muc_size.lua, and what needs to be 1) installed, 2) configured.

I have attempted to enable mod_muc_size (/usr/lib/prosody/modules/mod_muc_size.lua) to work.

These posts were intesting but not detailed enough for me to understand, and possibly not required for my installation?

I did attempt to install/configure some of the below ideas from the posts. And now I can restart prosody after enabling “muc_size” without errors being reported in prosody’s log file.

Here are my notes about lua5.2:

apt-get install liblua5.2-dev
wget https://keplerproject.github.io/luarocks/releases/luarocks-2.4.1.tar.gz
./configure --lua-version=5.2 --versioned-rocks-dir
make build
sudo make install
luarocks-5.2 install net-url

I also installed

luarocks-5.2 install basexx
luarocks-5.2 install luajwtjitsi

One post suggested accessing “muc_size”, information via this command, but it only returns page not found, so I guess “sessions” is not the name to use (but what is?).
curl http://localhost:5280/sessions

I think that you probably need to use http;//yoururl:5280/sessions, because the module is loaded in the host context, not localhost context (if you have even left it enabled)

I did find this information:
curl ‘http://localhost:5280/all-rooms?domain=conference.your.domain.com

and this

curl ‘https://localhost:5280/sessions

but since neither return any pages, I guess I have not been successful at getting mod_muc_size to work.

Thanks for your reply, yes, I have issues in that I have no instructions to follow.

It seems I was unsuccessful in getting mod_muc_size to work.

However I did find this information, not sure if it is correct or not. or how to translate to Apache2 conf

Added these lines in nginx config file (/etc/nginx/sites-available/.conf}
location = /room-size {
        proxy_pass http://localhost:5280/room-size?$args&domain=meeting.yepdesk.com;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host meeting.yepdesk.com;
        add_header Content-Type "application/json; charset=UTF-8";
        add_header 'Access-Control-Allow-Origin' '*';
    }

    location = /room-info {
        proxy_pass http://localhost:5280/room?$args&domain=meeting.yepdesk.com;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host meeting.yepdesk.com;
        add_header Content-Type "application/json; charset=UTF-8";
        add_header 'Access-Control-Allow-Origin' '*';
    }

    location = /sessions-info {
        proxy_pass http://localhost:5280/sessions?$args&domain=meeting.yepdesk.com;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host meeting.yepdesk.com;
        add_header 'Access-Control-Allow-Origin' '*';
    }

    location = /rooms {
        proxy_pass http://localhost:5280/room-list?$args&domain=meeting.yepdesk.com;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host meeting.yepdesk.com;
        add_header Content-Type "application/json; charset=UTF-8";
        add_header 'Access-Control-Allow-Origin' '*';
    }

what I’m trying to say is that you should not use localhost in your url path. You are talking to a prosody web server. Don’t mess with Apache when trying to make it work, it’s another matter entirely. Use curl but with your domain - you have a host entry for your Prosody host right ? So if your url is meet.helpdesk.org, use
http://meet.helpdesk.org:5280/sessions
never mind that meet.helpdesk.org resolves to 127.0.0.1 when you are launching this on your server, that’s the name that counts for Prosody web server routing.

Should this mean something:

netstat -anlp | grep 5280
tcp        0      0 0.0.0.0:5280            0.0.0.0:*               LISTEN      20156/lua5.2        
tcp6       0      0 :::5280                 :::*                    LISTEN      20156/lua5.2        
tcp6       0      0 ::1:5280                ::1:49518               ESTABLISHED 20156/lua5.2        
tcp6       0      0 ::1:49518               ::1:5280                ESTABLISHED 20215/apache2       
tcp6       0      0 ::1:5280                ::1:49400               TIME_WAIT   -                   
tcp6       0      0 ::1:5280                ::1:49420               TIME_WAIT   -                   
tcp6       0      0 ::1:5280                ::1:49374               TIME_WAIT   -                   
tcp6       0      0 ::1:5280                ::1:49372               TIME_WAIT   -

curl ‘http://meet.helpdesk.org:5280/sessions
curl: (6) Could not resolve host: meet.helpdesk.org
curl ‘http://jitsi.mydomain.com:5280/sessions
curl: (7) Failed to connect to jitsi.mydomain.com port 5280: Connection timed out

Maybe not, where is this entry ? Which file, which parameter?

yes that’s a bit confusing there are many hosts; I was thinking to /etc/hosts

/etc/hosts
has public IP address, not local ip address, which is why i guess people suggest https://localhost:5250
jitsi.mydomain.com jitsi

Mar 09 00:07:40 modulemanager	error	Error initializing module 'muc_size' on 'guest.jitsi.mydomain.com': error loading module 'cjson.safe' from file '/usr/local/lib/lua/5.2/cjson.so':

Well muc_size is not being loaded, it is now broken.

Without clear installation instructions, it is challenging to understand what needs to be loaded, and in what order, etc. If anyone has a clear set of instructions, it would be appreciate.

I have a hunch that something went wrong installing with luarocks.

apt-get install liblua5.2-dev
wget https://keplerproject.github.io/luarocks/releases/luarocks-2.4.1.tar.gz
./configure --lua-version=5.2 --versioned-rocks-dir
make build
sudo make install
luarocks-5.2 install net-url

with the public address it could work I guess. As I have a NATted server I’m not keen to try it.

As if your json error, it’s not linked to the URL I think :-). I can’t help you with luarocks, I have somehow a dislike of the very idea - don’t know why, luarocks is the reason I never tried JWT. So while this morning I was waiting for an internet download of 25 GB, I hacked mod_muc_size to work without luarocks. I got it to work, /sessions is not really of any interest except to show that it works, for room size I got

curl http://meeting.myserver.fr:5290/room-size?room=test1234\?domain=meeting.myserver.fr
{"participants":2}

Thanks for your help and support, gpatel-fr, it is appreciated.

I will try your example. I notice it is a different port to 5280.

I am no longer getting a muc_size error after removing luarocks packages I had installed, I then installed luarocks-5.2 packages.

luarocks remove luajwtjitsi
luarocks remove luaossl
luarocks remove lua-cjson
luarocks remove lbase64
luarocks remove luajwtjitsi
luarocks remove net-url
luarocks remove luaoss
luarocks remove luacrypto 
luarocks-5.2 install net-url
luarocks-5.2 install basexx
luarocks-5.2 install lbase64
luarocks-5.2 install luaossl
luarocks-5.2 install lua-cjson 2.1.0-1
luarocks-5.2 install luajwtjitsi
Installing https://luarocks.org/luajwtjitsi-2.0-0.src.rock
luajwtjitsi 2.0-0 is now installed in /usr/local (license: MIT <http://opensource.org/licenses/MIT>)

So maybe mod_muc_size is installed.

Is there a statement in a log file I can check to see if it is loading?

And if it is working, all I need to do is to find some way to test it.

If I am going to run

curl http://jitsi.mydomain.com:5280/room-size?room=John?domain=jitsi.mydomain.com

I will need some redirects in my apache2 conf file? Maybe not, as apache2 is not listening to 5280? Or should I connect to apache2 using port 443, and then have a redirect to 5280 ?

Are there any instructions for installing and configuring mod_muc_size ?

Note: my Jitsi server is behind a NAT firewall

I should have ‘fixed’ that, it’s the result of a test I did. It works by default on 5280 indeed.

no but you can enable the prosody debug in the global config file:

log = {
        -- Log files (change 'info' to 'debug' for debug logs):
        info = "/var/log/prosody/prosody.log";
        error = "/var/log/prosody/prosody.err";
        debug = "/var/log/prosody/prosody.dbg";  <<<<<<< uncomment here

if you do so, in the debug log you will see a line containing

…debug Serving ‘muc_size’ at http:/your-url…

you will address Prosody directly.

Embarrassing - While I had configured the NAT firewall and DMZ routing, I forgot to open port 5280 on the actual server’s firewall.

I realised the firewall issue this using:

netcat -z -v -t jitsi.mydomain.com 5280

However when I use the following curl command, I get prosody errors:

curl 'http://jitsi.mydomain.com:5280/room-size?room=John?domain=jitsi.mydomain.com'
<title>500 Internal Server Error</title>
Mar 09 12:28:42 runnerOKnRDbGq    error    Encountered error: /usr/share/jitsi-meet/prosody-plugins/mod_muc_size.lua:91: attempt to concatenate local 'domain_name' (a nil value)
stack traceback:
    /usr/share/jitsi-meet/prosody-plugins/mod_muc_size.lua:91: in function 'handler'
    /usr/share/jitsi-meet/prosody-plugins/util.lib.lua:136: in function 'func'
    /usr/lib/prosody/util/async.lua:127: in function </usr/lib/prosody/util/async.lua:125>
Mar 09 12:28:42 http.server    error    Traceback[httpserver]: /usr/lib/prosody/util/async.lua:137: /usr/share/jitsi-meet/prosody-plugins/mod_muc_size.lua:91: attempt to concatenate local 'domain_name' (a nil value)
stack traceback:
    /usr/share/jitsi-meet/prosody-plugins/mod_muc_size.lua:91: in function 'handler'
    /usr/share/jitsi-meet/prosody-plugins/util.lib.lua:136: in function 'func'
    /usr/lib/prosody/util/async.lua:127: in function </usr/lib/prosody/util/async.lua:125>
stack traceback:
    [C]: in function 'error'
    /usr/lib/prosody/util/async.lua:137: in function 'handler'
    /usr/lib/prosody/util/async.lua:211: in function 'run'
    /usr/share/jitsi-meet/prosody-plugins/util.lib.lua:159: in function </usr/share/jitsi-meet/prosody-plugins/util.lib.lua:123>
    (...tail calls...)
    /usr/lib/prosody/util/events.lua:79: in function </usr/lib/prosody/util/events.lua:75>
    (...tail calls...)
    /usr/lib/prosody/net/http/server.lua:248: in function </usr/lib/prosody/net/http/server.lua:176>
    [C]: in function 'xpcall'
    /usr/lib/prosody/net/http/server.lua:108: in function 'process_next'
    /usr/lib/prosody/net/http/server.lua:124: in function 'success_cb'
    /usr/lib/prosody/net/http/parser.lua:177: in function 'feed'
    /usr/lib/prosody/net/http/server.lua:155: in function </usr/lib/prosody/net/http/server.lua:154>
    (...tail calls...)
    /usr/lib/prosody/net/server_select.lua:915: in function </usr/lib/prosody/net/server_select.lua:899>
    [C]: in function 'xpcall'
    /usr/bin/prosody:80: in function 'loop'
    /usr/bin/prosody:90: in main chunk
    [C]: in ?

The mod_muc_size code:

function handle_get_room (event)
    if (not event.request.url.query) then
        return { status_code = 400; };
    end

    local params = parse(event.request.url.query);
    local room_name = params["room"];
    local domain_name = params["domain"];
    local subdomain = params["subdomain"];
    local room_address
        = jid.join(room_name, muc_domain_prefix.."."..domain_name);

    if subdomain and subdomain ~= "" then
        room_address = "["..subdomain.."]"..room_address;
    end

    if not verify_token(params["token"], room_address) then
        return { status_code = 403; };
    end

    local room = get_room_from_jid(room_address);
    local participant_count = 0;
    local occupants_json = array();

huh, I think you were misled by my post :-(. I said that I had hacked the code and in doing so, introduced a small bug, and it reflected in the incorrect syntax of the curl instruction I posted carelessly. Try with:

curl 'http://jitsi.mydomain.com:5280/room-size?room=John&domain=jitsi.mydomain.com'

this is the correct syntax to pass several parameters to an URL and the use of a ‘?’ instead of ‘&’ caused the ‘normal’ code of the module to ignore the second parameter, and as it’s mandatory the whole thing crashed.

Well that stopped it from crashing. But did not return any information.

Here is the /var/log/prosody/prosody.log with debug enabled.

Mar 09 23:28:00 socket	debug	server.lua: accepted new client connection from [ext.ip.addr]:49286 to 5280
Mar 09 23:28:00 http.server	debug	Firing event: GET /room-size
Mar 09 23:28:00 http.server	debug	Firing event: GET jitsi.mydomain.com/room-size
Mar 09 23:28:00 runnerbaeTUZfz	debug	creating new coroutine
Mar 09 23:28:00 general	debug	Querying room John@conference.jitsi.mydomain.com
Mar 09 23:28:00 general	debug	no such room exists
Mar 09 23:28:00 socket	debug	server.lua: client [ext.ip.addr]:49286 read error: closed
Mar 09 23:28:00 socket	debug	server.lua: closed client handler and removed socket from 

Please check my previous posts for the luarocks-5.2 modules I have installed, I have an idea I am missing one (or two), but since I cannot find a list of which ones I should install, I have no way to know.

Looks like everything required is installed, judging my this statement;

https://community.jitsi.org/t/jitsi-monitoring-mod-room-list-occupant-list/31191/46
Installed luarocks (v. 5.2)
Installed via luarocks net-url, basexx, luajwtjitsi and lua-cjson
As luajwtjitsi needs git, installed git
luajwtjitsi needs also luacrypto and lbase64
When I had all these installed… things didn’t work: there were warnings about failed dependencies in prosody err log. Until I removed luajwtjitsi dependencies luacrypto and lua-cjson and installed exactly the minimum versions luajwtjitsi neeed (at first I did install the newest versions at my reach).
After all that, things are working like a charm.

ah yes, internally Jitsi-meet lowercases all rooms name. Try with ‘john’