Multiple Apps Calling `le_avdata_RequestSession`


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?


Missing Call to AirVantage Session State Handler

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).




@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?



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.



@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?



Glad I could help.

@Prush also deserves credit too.