No connection! relogin too often

Hello,
I’d like to use this app, but every now and then I got “No connection! relogin” message.
We use OC_User_IMAP backend and ejabberd as XMPP server (that also uses external authentication to email - basically email account is all that user needs for everything).
When I activate app, user logs in, he is immediately log in to XMPP with this app. But after a few minutes (I think it happens when user close NC tab and reopen it few minutes later), he needs to relogin to XMPP.
For my purpose, not having this app is less evil than relogin every time user wants to chat with somebody.

Just increase the max_inactivity value in your ejabberd config.

This won’t solve the problem, unless I increase it to NC session lifespan.
I presume only working solution would require to save user passwords somewhere on NC server and reconnect as needed, which is not very secure. Or some php background worker, that keeps connection alive, as long as needed.

There is a third possibility: Our new xmpp-cloud backend with time-limited tokens. Those tokens can be generated by ojsxc and used to login to your xmpp server everytime your connection expires. We already prepared this expect the ui, but we currently put all our effort in refactoring jsxc. If you like you can open a pr and we discuss further details.

Hmmm, interesting. I think I could just take token verify_token function from xmpp-cloud-auth script and add it to my current auth script if default auth method fail.
I see that ojsxc value apiSecret already exists in NC and it was generated securely, so I don’t need to generate it myself.
I think I’ll try this tomorrow and let you know how it went.
Thanks

Well, it almost works.
Almost, because OJSCX is generating token using JID name@domain@domain.
I found what’s wrong, fixed it and created pull request.

Now I’ll observe, if OJSXC will relog automatically when token expire after 1 hour of inactivity.

Hmm I came back from lunch and I got “No connection! relogin” again.

What XMPP server are you using? Prosody has some problems with the mod_auth_external module which then talks to our xmpp-cloud-auth. I therefore currently recommend ejabberd (but we consider working on a replacement to mod_auth_external.lua.

We also have some installation/setup instructions which might help setting up NC+HTTPS+XMPP.

I use ejabberd.
In current configuration ejabberd authenticate against mail server (or rather same PostgreSQL database as mail server). Alternatively if this auth fails it will try to use OJSXC token auth.
NC authenticate against same mailserver with OC_User_IMAP.

So far as I can tell, when I log into NC, OJSXC successfully logs in to ejabberd with token (not password). So far so good. But when I close tab and reopen it later and my NC session is still alive, OJSXC won’t try to relogin to XMPP server using newly generated token, instead it immediately shows “No connection! relogin” message.

OJSXC won’t try to relogin to XMPP server using newly generated token

This is currently not implemented, as you can see in the following issue: