Project

General

Profile

Custom procedure TigUserLogout doesn't always run. Roster is not correct after relogin through jabber client.

Dmitry Anatolievich
Added over 4 years ago

Hello, everyone.

I use the custom auth connector. I have CustomTigUserLogin stored procedure.

Now it looks, like this:

...

IF EXISTS(SELECT 1 FROM vpopmail WHERE (CONCAT(pw_name, '@', pw_domain) = p_user_id) AND (pw_passwd = p_encrypted_passwd))

AND EXISTS(SELECT 1 FROM tigase.tig_users WHERE user_id = p_user_id)

THEN

CALL tigase.CustomRestoreRoster(p_user_id);

SELECT p_user_id AS user_id;

ELSE

SELECT NULL AS user_id;

END IF;

...

Before sending the user_id, I restore the user roster (directly at the database, at the table tig_pairs).

When i log in through jabber client first time, the roster is correct.

But if i add some users directly to database, and after this do log off, and do log in again through client, the roster of client is not correct (without my changes from CustomRestoreRoster procedure). It has old values. At the database roster is correct (with my changes from CustomRestoreRoster procedure).

In this situation helps only restart Tigase server.

It seems, like Tigase saves roster not only at the database.

May be you have any idea, why it happens?

Thx and best regards.


Replies (3)

Added by Dmitry Anatolievich over 4 years ago

Hello, everyone, again.

I noticed something. So, i will update my previous question.

As i wrote before, I use the custom auth connector.

It is from my init.properties file:

config-type=--gen-config-def

--admins=admin@xmpp.dev.aaaaa.it

--virt-hosts=xmpp.dev.aaaaa.it

--debug=server

--user-db=mysql

--user-db-uri = jdbc:mysql://localhost/tigase?user=root&password=rf.-p0az<Q

--auth-db = tigase-custom

--auth-db-uri = jdbc:mysql://localhost/vpopmail?user=testuser&password=testuser

--tigase.cache=false

basic-conf/auth-repo-params/conn-valid-query=select 1

basic-conf/auth-repo-params/init-db-query=

basic-conf/auth-repo-params/user-login-query={ call CustomTigUserLogin(?, ?) }

basic-conf/auth-repo-params/users-count-query=

basic-conf/auth-repo-params/add-user-query=

basic-conf/auth-repo-params/del-user-query=

basic-conf/auth-repo-params/update-password-query=

basic-conf/auth-repo-params/user-logout-query={ call CustomTigUserLogout(?) }

I noticed, that my CustomTigUserLogout runs not each time, when user logs off through jabber client.

CustomTigUserLogin runs every time, when i log in through jabber client.

So, i think that this problem is the same as and for roster, that i wrote before.

I found in one article, that roster is stored at the server memory, when user online.

And in my case, i think, i have some issue, when user logs off through the client. It works incorrect, and as result CustomTigUserLogout procedure runs not each time, and roster doesn't terminate from memory.

I need your help. Why does CustomTigUserLogout procedure run not each time, when user logs off?

It is very important for me.

Thx.

Added by Wojciech Kapcia TigaseTeam over 4 years ago

This is relatively old problem - and as an aftermath we don't recommend on relying on online_status filed - there were a number of reports that it's value is incorrect over the time and fro the same reason you are experiencing - CustomTigUserLogout may not be run each time user goes offline. The reason for that is that the user session may be terminated incorrectly (apart from proper xmpp disconnection there may be network failure, etc). As a conclusion - I would not recommend basing your solution on that event as it may not be the most reliable source of information whether user is online or offline. Furthermore - instead of modifying rosters on the fly I would suggest using (suggested in separate thread) Dynamic rosters as it should solve almost all your issues with providing tailored,unmodifiable roster for user.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

All the Wojciech's comments about relying on online_status is true. It is not reliable for many reasons. However, CustomTigUserLogout should be run every time user disconnects. If it is not called sometimes then it is a bug and we have to fix it. But....

  1. There is no guarantee when the function will be called, as sometimes discovery of user disconnection may take a long time. There is also a use case when user disconnects and reconnects before Tigase discovers user's disconnection. What do we do then? Even then CustomTigUserLogout should be run, but will it conflict with the CustomTigUserLogin?

  2. Another thing is the case when you have a bunch of users logged in and you restart the server. Then the method CustomTigUserLogout will not be run for all connected users. So you need to keep this in mind.

  3. Yet another thing to keep in mind how the whole logic works for multiple users connections or in a cluster mode when different nodes may call each of the procedure simultaneously.

    (1-3/3)