Multiple Apps Calling `le_avdata_RequestSession`

#1

Our current product implementation has multiple apps making calls to le_avdata_RequestSessoin. Is this recommended or is it considered best practice to have one app manage and push data to AIrVantage?

Thanks

Missing Call to AirVantage Session State Handler
#2

It should be fine to have multiple apps calling le_avdata_RequestSession(). The idea is that the session will remain open as long as any one app has an active request to have a session open (and there’s a good IP connection to the AV servers).

Cheers,

–Jen

#3

@jchitty . Thanks for the tip. You qualified your answer with a good IP connection to the AV servers but what if the connection isn’t good?

Earlier this week I was troubleshooting our apps when we have poor connection issues

I have changed our sensorToCloud app to now release the session before creating a new one but since we have other sessions open this may not work, right?

Also, what’s the recommended way to coordinate a session across apps?

Thanks,
Darren

#4

I added that qualification just because, if there isn’t a good IP connection, then there can’t be a session open, no matter how many apps are requesting one. :slight_smile:

I previously expected that the AV Data service would take care of retrying when the session is lost while there are still outstanding requests for the session to be open, but it appears that it does not currently work like that.

According to @Prush, after you’ve established a session, if you get a SESSION_STOPPED notification, then all session requests are essentially dead, so all apps that have called le_avdata_RequestSession() should respond to the SESSION_STOPPED by calling le_avdata_ReleaseSession() to free the memory associated with the previous request, and then call le_avdata_RequestSession() to create a new request for another session.

What I said previously about multiple apps still stands. It is safe to have multiple apps independently requesting sessions, without any coordination between them. But they each have to independently register for notification of session state changes and respond to the SESSION_STOPPED by releasing and re-requesting a new session if they still need a session.

I hope this is clear.

–Jen

#5

@jchitty Yes it is very clear, thank you for the detailed explanation!

I just noticed that two of the three apps don’t call le_avdata_AddSessionStateHandler which is incorrect from what you have described above, right?

#6

Right!

Glad I could help.

@Prush also deserves credit too.