android-client-sdk icon indicating copy to clipboard operation
android-client-sdk copied to clipboard

ConnectionInformation doesn't get updated after identifying to a different context

Open anawu2006 opened this issue 2 years ago • 4 comments

Is this a support request? No

Describe the bug In SDK 3.6.0, LDClient.get().connectionInformation will get updated with a new lastSuccessfulConnection value after identifying to a different user, but not in 5.0.0.

To reproduce

  1. init LDClient with ldContext1 and register a LDStatusListener
    LDClient.init(context, config, ldContext1, 3)
    LDClient.get().registerStatusListener(statusListener)
    
  2. switch to ldContext2:
    LDClient.get().identify(ldContext2)
    
  3. LDClient.get().connectionInformation doesn't get updated and LDStatusListener.onConnectionModeChanged doesn't get triggered.

Expected behavior LDClient.get().connectionInformation should be updated with a new lastSuccessfulConnection value and LDStatusListener.onConnectionModeChanged` should be triggered.

Logs None.

SDK version 5.0.0

Language version, developer tools Android Kotlin, API 34

OS/platform Android 13

Additional context I have checked the source code of ConnectivityManager.setStatusand noticed that LastSuccessfulConnection value won't be updated if the ConnectionMode doesn't change. I think the connection information should be updated in this case given the LDContext changed. But feel free to close this out if you don't think so.

anawu2006 avatar Aug 07 '23 09:08 anawu2006

Hi @anawu2006 , thank you for reporting this. We believe this bug has been in the code base since 4.x and has been overlooked. We have filed this internally as 211876.

Could you tell us a bit about how you are using the listener in your code base and the impact of this bug on your application? This will help us prioritize it against other issues. Thank you for taking the time to report!

tanderson-ld avatar Aug 07 '23 18:08 tanderson-ld

@tanderson-ld you are correct, this bug exists in 4.x as well.

In our app, having a new successful connection to LD server is one of the conditions when switching users/contexts. So after identifying, we wait until LDStatusListener.onConnectionModeChanged gets triggered with a new connectionInformation.lastSuccessfulConnection value.

With this issue, we are not able to switch users/contexts successfully. Any other suggested solutions to identify a new successful connection to server after identifying? Thanks.

anawu2006 avatar Aug 08 '23 01:08 anawu2006

Sorry for the delay @anawu2006 . Could you try setOffline(), identify, then setOnline()? I think that is enough to get the connection manager to change states.

tanderson-ld avatar Aug 17 '23 15:08 tanderson-ld

@tanderson-ld no worries and that is exactly what I had put up to bypass this issue. Thanks.

anawu2006 avatar Aug 18 '23 03:08 anawu2006

@anawu2006 , this issue should now be fixed in version 5.3.1 which was just released. Please be aware that the SDK may send multiple updates in quick succession with just the last connection timestamp updated.

tanderson-ld avatar Jul 10 '24 18:07 tanderson-ld