0
votes

I am using ejabberd-18.09. According to the documentation I think that a temporary room should get deleted once every member of the room leaves the room.

But in our I can see on ejabberd dashboard that rooms created even a month ago are still present on the server.

I can see this on the ejabberd dashboard

JabberID ->   [email protected]
participants -> 0
Last message -> A long time ago
Public -> true  
Persistent -> false
Logging -> false
Justcreated -> true

and there are hundereds of rooms with similar info.

My room configuration is like this

    host: "conference.@HOST@"
    access:
      - allow
    access_admin:
      - allow: admin
    access_create: all
    access_persistent: muc_create
    default_room_options:
      allow_change_subj: false
      allow_query_users: true
      allow_private_messages: true
      members_by_default: true
      anonymous: true
    max_users: 10

I am a bit lost here. Why is it happening ?

Can anyone help me out here please ?

EDIT

I am using mod_muc:create_room/5 to create the room. Then I send direct Invitation to other users from the ejabberd to other users, which they accept and then join the chat room.

For destroying the rooms the client send destroy packet to destroy the chat in regular scenario, but if our client fails to send the destroy packet after a certain time of room creation(for different reasons like app being in background, a phone call etc etc) they just leave the room and in such cases I was hoping that the transient rooms would play their part where they get destroyed after everyone leaves.

The are the logs in the ejabberd.log file

<0.23497.0>@mod_muc_room:init:137 Created MUC room [email protected] by [email protected]/xiaomi

<0.23476.0>@ejabberd_c2s:process_terminated:262 (tcp|<0.23476.0>) Closing c2s session for [email protected]/xiaomi: Stream reset by peer
2019-08-26 17:15:13.201 [info] <0.23497.0>@mod_muc_room:close_room_if_temporary_and_empty:1120 Destroyed MUC room [email protected] because it's temporary and empty
2019-08-26 17:15:13.201 [info] <0.23497.0>@mod_muc_room:terminate:703 Stopping MUC room [email protected]

In the ejabberd dashboard there are some rooms with values

JabberID ->   [email protected]
participants -> 0
Last message -> A long time ago
Public -> true  
Persistent -> false
Logging -> false
Justcreated -> true

While there are some as

JabberID ->   [email protected]
participants -> 1
Last message -> A long time ago
Public -> true  
Persistent -> false
Logging -> false
Justcreated -> false

mostly the pattern is that the rooms with 0 ocupants have Justcreated as true while the once with 1 participant left has Justcreated as false.

2

2 Answers

0
votes

According to the documentation I think that a temporary room should get deleted once every member of the room leaves the room.

Right.In the ejabberd log file, when a user joins a new room:

18:04:06.637 [info] Created MUC room [email protected] by user3@localhost/tka1
User leaves the room:
18:04:11.143 [info] Destroyed MUC room [email protected] because it's temporary and empty
18:04:11.144 [info] Stopping MUC room [email protected]

What do you see in ejabberd.log when a room is created and then the user leaves it?

But in our I can see on ejabberd dashboard that rooms created even a month ago are still present on the server.

How are the rooms created?

If you create one using a desktop Jabber client (for example Gajim, Psi, or other), does that room also keep alive after user leaves?

Justcreated -> true

Umm, this is weird. Just created is set to true when the room has just been created. Immediately the code to join the first user is executed, and that code sets Justcreated to the timestamp of that user.

All your empty rooms and temporary rooms have Justcreated true?

0
votes

I am using mod_muc:create_room/5 to create the room. Then I send direct Invitation to other users from the ejabberd to other users

Better use the API provided for admins:

$ ejabberdctl create_room room2 conference.localhost localhost
$ ejabberdctl send_direct_invitation room2 conference.localhost "" "Join this cool room" user4@localhost

BTW; I found a problem in ejabberd, try applying this patch, so the command create_room doesn't create a forced persistent room:

diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl
index 805e72481..9aed4a017 100644
--- a/src/mod_muc_admin.erl
+++ b/src/mod_muc_admin.erl
@@ -623,10 +623,7 @@ justcreated_to_binary(J) when is_atom(J) ->
 %%       ok | error
 %% @doc Create a room immediately with the default options.
 create_room(Name1, Host1, ServerHost) ->
-    case create_room_with_opts(Name1, Host1, ServerHost, []) of
-        ok -> change_room_option(Name1, Host1, <<"persistent">>, <<"true">>);
-        Error -> Error
-    end.
+    create_room_with_opts(Name1, Host1, ServerHost, []).

 create_room_with_opts(Name1, Host1, ServerHost, CustomRoomOpts) ->
     true = (error /= (Name = jid:nodeprep(Name1))),