PubSub messaging breaks on user logout

Please provide steps to reproduce the issue with user update because the next scenario works fine for me:

  1. login
  2. join default channel
  3. add message listener
  4. send message - message is received
  5. update user - user is successfully updated
  6. send message - message is received
  7. logout
  8. wait until channel is joined automatically again (it’s an expected behaviour because we need to reconnect socket after logout with a new settings and then resubscribe for all subscriptions including messaging)
  9. send message - message is received
  10. login
  11. wait until channel is rejoined automatically again (it’s an expected behaviour because we need to reconnect socket after login with a new settings)
  12. send message - message is received
  13. update user - user is successfully updated
  14. send message - message is received

Regards,
Olha

Hello @Hrvoje_Ditrih,

A new version of Swift-SDK v6.2.1.1 with fixes is released. Could you please check?

Regards,
Olha

Hello,

The issue with reconnect after the internet disconnects is now solved.

But there is still an issue when updating user with:
[Backendless.shared.userService updateWithUser:]

We discovered that when the stay logged in flag is set:
Backendless.shared.userService.stayLoggedIn = YES;
and when user update is called the joined channels join again.

I’ll check this. Ticket number is BKNDLSS-23739.

Regards,
Olha

It seems like that stayLoggedIn flag forces the socket to reconnect, on user update, whilst re-joining all joined channels.

For us, the stayLoggedIn flag in conjunction with validating user token doesn’t work as expected - even if we set the flag to NO, when the app relaunches the user token will still be valid.

Hi @olhadanylova ,

Can you please expedite this issue with your development team? We need to release our app and this is one of the main issues we encounter.
As Hrvoje mentioned, the issue arises when the Backendless.shared.userService.stayLoggedIn = YES; flag is set.
Even though the disconnect issues have been fixed with some of the later builds, the problem where the flag is set causes the malfunction in PubSub subscription where it breaks completely, user cannot receive any messages anymore which is a dealbreaker for us.

I see another couple of builds after your last interaction with our dev, however they don’t seem to be related to our use case - can you confirm?

Thanks for your help so far.

Best,

Matej.

Hello @Matej_Trbara,

The ticket is in progress right now and the fix will arrive soon.
However, I’d ask you to provide steps of the expected and current behaviour to test the fix as close as possible to your scenario (as it was done in the first comment).

Regards,
Olha

Hello,
issue with channel reconnection after current user update is fixed.
Please check with Swift-SDK v6.2.5.

Here are steps of our tests:

  1. login user
  2. connect to the default channel
  3. add message listener
  4. send message - the message is received
  5. update user
  6. send message - the message is received
  7. logout user - the default channel is rejoined automatically as expected
  8. send message - the message is received
  9. check token - token is invalid (because user was logged out)
  10. login user - the default channel is rejoined automatically as expected
  11. check token - token is valid
  12. send message - the message is received

Please provide your steps if issue still occurs.

Regards,
Olha

Hi @olhadanylova ,

There is still a certain situation when RT messaging stops working (Swift-SDK v6.2.10.). Here are steps to reproduce the issue.

  1. login user
  2. connect to channel
  3. add message listener
  4. send message - the message is received
  5. logout user

These next steps you need to do fast one after the other. You can wait for user to properly login but then you need to remove and add message listeners very fast.

  1. login user
  2. remove message listeners (do it fast after 6.)
  3. add message listener (do it fast after 7.)
  4. remove message listener (do it fast after 8.)
  5. add message listener do it fast after 9.)
  6. send message - the message is not received

Regards,
Hrvoje

Hello @olhadanylova

Our engineer will check and write here additionally about the result.

Hello @Hrvoje_Ditrih,

Please check with v6.3.0.

Regards,
Olha

Hi @olhadanylova ,

The problem still isn’t fixed. After you do logout and then login there is a period when Backendless reconnects. You can track the Backendless connection with these listeners:
Backendless.shared.rt addConnectEventListenerWithResponseHandler
and
Backendless.shared.rt addDisсonnectEventListenerWithResponseHandler

After logout and then login, there are few seconds after Beckendless connects. If you add/remove message listners in a period when Backendless still isn’t connected they won’t work. If you add/remove message listeners after Backendless connect, it works fine.

Regards,
Hrvoje

Hi @olhadanylova,

Also on the note of the general Swift-Backendless SDK. There are numerous issues when using login/logout. It’s very hard to reproduce these issues, for eg. the last issue I reported took me 2 months to figure out how to reproduce the issue on a minimal example. It would be very benefitial for us if you could do a close examination of login/logout and everything that is connected to it and fix those issues.

We have been using Backendless for more than 4 months now and our app still can’t logout/login properly. Sometime it works fine and sometimes the whole app breaks after user does login after logout because of some issue with Backendless. Our temporary fix for this situation is that when the user wants to logout we quit the app after logout. Then login works properly after fresh startup of the app. It would be great for us if you could examine the login/logout workflow and make sure that Backendless works the same after them.

Best,
Hrvoje

Hi @Hrvoje_Ditrih

After logout and then login, there are few seconds after Beckendless connects.

It’s strangely big delay. The delay between disconnect and reconnect events for us is few hundred of milliseconds.

If you add/remove message listners in a period when Backendless still isn’t connected they won’t work.

We cannot reproduce this case. If we add listeners before socket is reconnected, they works correctly. Would be great if you create minimal reproducible example with this issue and share it.

There are numerous issues when using login/logout.

RT connection uses user token that is why login\logout events and rt listeners are linked. And we are glad you’ve discovered this issue and helped us to resolve it.

Our temporary fix for this situation is that when the user wants to logout we quit the app after logout.

I agree, this is very rough workaround. If you are not sure about RT stability you can just remove and then re-add all necessary listeners after logout by yourself. There is no need to restart whole app.

Best Regards,
Maksym

It’s strangely big delay. The delay between disconnect and reconnect events for us is few hundred of milliseconds.

Well for us it is a second or more. Our requests for Backendless API Services on CloudCode take 2-3 seconds sometimes. It could be because we are in Europe and Backendless servers are in US.

We cannot reproduce this case. If we add listeners before socket is reconnected, they works correctly. Would be great if you create minimal reproducible example with this issue and share it.

I already did. @olhadanylova has the source code and here is the post.

I agree, this is very rough workaround. If you are not sure about RT stability you can just remove and then re-add all necessary listeners after logout by yourself. There is no need to restart whole app.

We tried everything: adding/removing listeners, joining/leaving channels, tried adding/removing/joining/leaving at every possible time point of Backendless lifecycle. But it still wouldn’t work sometimes. It only works when the user is already logged in on app startup or when user logs in after the fresh app startup.

We were able to finally reproduce this issue. I’ve updated the internal ticket BKNDLSS-23739. We will keep you with a progress of this task.

Backendless has a cluster in Europe too:

Regards,
Mark

Hi @mark-piller,

We know. But we made Backendless app before you had European cluster.

Hi, @Hrvoje_Ditrih

If you would like, we can always change the hosting zone. The process takes about 3-4 hours. Application ID and API keys won’t change, however the api endpoint will change from api.backendless.com to eu-api.backendless.com. Also, this will coast additional fee to cover engineer’s time.

Regards, Marina

Hello @Hrvoje_Ditrih,

Sorry for the delay and thank you for your patience. Unfortunately the RT logic sometimes can be a little confusing and it may cause some issues.
A new version 6.3.1 is released. Could you please check? For me it works fine now and listners added while Backendless isn’t connected should work fine.

Regards,
Olha