# Multiple Apps Calling \`le\_avdata\_RequestSession\`

**URL:** <https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646>\
**Category:** Build your own\
**Created:** [May 16, 2019, 6:19pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646 "2019-05-16T18:19:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 16, 2019, 6:19pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/1 "2019-05-16T18:19:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jchitty](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jchitty/32/846_2.png) [@jchitty](https://mangoh.discourse.group/u/jchitty)\
**Post date:** [May 16, 2019, 9:05pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/2 "2019-05-16T21:05:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 16, 2019, 9:10pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/3 "2019-05-16T21:10:54Z")

</div>

@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](https://mangoh.discourse.group/t/poor-signal-quality-and-air-vantage-data-costs/2636/8)

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

---

<div class="post-metadata">

**Author:** ![jchitty](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jchitty/32/846_2.png) [@jchitty](https://mangoh.discourse.group/u/jchitty)\
**Post date:** [May 16, 2019, 10:29pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/4 "2019-05-16T22:29:55Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 16, 2019, 10:37pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/5 "2019-05-16T22:37:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jchitty](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jchitty/32/846_2.png) [@jchitty](https://mangoh.discourse.group/u/jchitty)\
**Post date:** [May 16, 2019, 11:34pm UTC](https://mangoh.discourse.group/t/multiple-apps-calling-le-avdata-requestsession/2646/6 "2019-05-16T23:34:44Z")

</div>

Right!

Glad I could help.

@Prush also deserves credit too.
