# Ensuring reliable cell connection and retrying?

**URL:** <https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043>\
**Category:** mangOH Red\
**Created:** [December 30, 2017, 3:54am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043 "2017-12-30T03:54:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![coastalbrandon](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/coastalbrandon/32/264_2.png) [@coastalbrandon](https://mangoh.discourse.group/u/coastalbrandon)\
**Post date:** [December 30, 2017, 3:54am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/1 "2017-12-30T03:54:21Z")

</div>

Hey team,

We have been quite successful with our project so far and we are encountering another hurdle we are getting over. Our system will run for about 24 hours connected to the network, but will mysteriously go offline and not re-connect. We are looking for suggestions on how we should be handling our data connections, here is our proposed flow:

le\_avdata\_AddSessionStateHandler to manage the session with Air Vantage.  
PollForConnection to see if we’re online (sometimes it says we’re online when we actually aren’t)  
If our publish fails we are considering using le\_mrc\_interface (modem radio control) and power cycling the radio. Is this a good idea? Or will this just cause us pain?

We have been looking at the RedSensorToCloud repo, but it doesn’t seem to have any way of connecting and disconnecting from the network and retrying if it cannot connect.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [December 30, 2017, 5:21am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/2 "2017-12-30T05:21:15Z")

</div>

@dclark75 can you see if some of the patches you have can help here?

@coastalbrandon Maybe you can see if these patches help your issue

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 7:11am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/3 "2017-12-30T07:11:34Z")

</div>

What legato version is using?  
I had the same problem with legato 17.06.  
Now with legato 17.11 all work fine (4 mangos without problem). I push data every 15mn with heartbeat set to 1h.

---

<div class="post-metadata">

**Author:** ![munirchowdhury](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@munirchowdhury](https://mangoh.discourse.group/u/munirchowdhury)\
**Post date:** [December 30, 2017, 2:50pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/4 "2017-12-30T14:50:50Z")

</div>

Have you checked why the network operator has thrown you out? some networks deny the radio resources to make sure that the connected device isn’t just stuck and deny radio resources. You may want to check the cause from le\_mrc\_NetworkRejectHandlerRef\_t. if you don’t get immediate re-registration, you could scan the PLMN and attempt to register to the next available network and loop through the list. Once you are able to get onto an alternative network, your original network network should unblock you so that you can go back to it at a later date.

---

<div class="post-metadata">

**Author:** ![coastalbrandon](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/coastalbrandon/32/264_2.png) [@coastalbrandon](https://mangoh.discourse.group/u/coastalbrandon)\
**Post date:** [December 30, 2017, 4:13pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/5 "2017-12-30T16:13:33Z")

</div>

Thanks, all!

So, just so I’m clear - does legato automatically try to handle the connection through the session handler? If it loses connection does it try to re-connect? Or would it normally not try unless you’ve implemented a state machine that’s manually checking whether it has a connection?

We are running Legato 17.07.2… I’ll have to talk to @nick, but I believe there may be some breaking changes that we need to account for in an upgrade to 17.11.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 7:35pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/6 "2017-12-30T19:35:33Z")

</div>

Sierra support confirm 17.11 fixe issue with AirVantage push. My application just open a session at startup and push every xx minut.

In 17.06/17.07 I was not choice to close and restart session every 06h…

With 17.11 all work fine

---

<div class="post-metadata">

**Author:** ![coastalbrandon](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/coastalbrandon/32/264_2.png) [@coastalbrandon](https://mangoh.discourse.group/u/coastalbrandon)\
**Post date:** [December 30, 2017, 8:49pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/7 "2017-12-30T20:49:09Z")

</div>

Awesome, that’s good news Francis.

We just upgraded to 17.11 and that was very smooth. We have added a retry timer if our AVSession returns failed, the retry timer power cycles the radio after waiting 2 minutes, 4 mins, 8 mins, or 16 mins depending on how many retries it’s attempted. When we turn off the radio we release the session, which probably doesn’t matter, and when we turn on the radio again we force the state to ‘no connection’ again in order for our loop to validate our connection.

Hoping to test this over the next 24 hours or so on 4 MangOH red units.

A side note - we confirmed that our connections had all died after 12 hours in the past… which doesn’t seem like a coincidence. The way to get them back was to power cycle the radios on the units.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 8:54pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/8 "2017-12-30T20:54:29Z")

</div>

One question : what code do you use to turn on off the radio ?

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 8:56pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/9 "2017-12-30T20:56:55Z")

</div>

I confirm for the 12 hours

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 30, 2017, 8:59pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/10 "2017-12-30T20:59:45Z")

</div>

@Francis.duhaut Use the `le_mrc` API as specified here: [http://legato.io/legato-docs/latest/le\_\_mrc\_\_interface\_8h.html](http://legato.io/legato-docs/latest/le __mrc__ interface_8h.html)

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 9:00pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/11 "2017-12-30T21:00:22Z")

</div>

Please have a look on this topic it’s very important  
It work fine for me

> [@Install application from airvantage](http://mangoh.discourse.group/t/install-application-from-airvantage/1002/15):
>
> Hi @nilsarve, I am glad I could help and add to developer community for mangOH. My team hated the rollback especially with all the changes in the asset creation.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 9:04pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/12 "2017-12-30T21:04:51Z")

</div>

Legato 17.11 is not enough to solve completely your problem, modify the model app as indicate on my previous message.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 30, 2017, 9:09pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/13 "2017-12-30T21:09:20Z")

</div>

@Francis.duhaut Which problem are you referring to? Keeping the device online (this topic) and getting AirVantage updates to work (the other topic you posted a link to) are completely separate concerns.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 9:14pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/14 "2017-12-30T21:14:18Z")

</div>

With my small experience the legato 17.11 and a modification of model app have solve all my connection problem.

With legato 17.06 and old model app I lost connection every 12h and the heartbeat was not working good.

Now all is perfect with same app.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [December 30, 2017, 9:16pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/15 "2017-12-30T21:16:22Z")

</div>

To keep alive the connection I use the heartbeat with a small value (30mn)

---

<div class="post-metadata">

**Author:** ![coastalbrandon](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/coastalbrandon/32/264_2.png) [@coastalbrandon](https://mangoh.discourse.group/u/coastalbrandon)\
**Post date:** [December 31, 2017, 7:06pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/16 "2017-12-31T19:06:29Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/b1f47db24b51b2cdadd08f2e4d8bdc4ffeb0eefb.png)

Just as a heads up, we ran into a new problem overnight on one of our units… Not sure if it will appear on our other units or not, but the avPublisher claims that it ran out of memory. It may be us causing a memory leak somewhere, but this is new after our latest update to 17.11 legato.

---

<div class="post-metadata">

**Author:** ![coastalbrandon](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/coastalbrandon/32/264_2.png) [@coastalbrandon](https://mangoh.discourse.group/u/coastalbrandon)\
**Post date:** [January 1, 2018, 2:38am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/17 "2018-01-01T02:38:25Z")

</div>

One further thing that’s new today after upgrading to 17.11 is one of our units is succesfully publishing, but AirVantage is showing ‘no communication available’. We can see that we have the right number of data points that have been received by AV, but we just don’t see the data on the platform.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/b386af3015d947a8809d3ca4c03ff83078e8dfed.png)

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [January 1, 2018, 10:30am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/18 "2018-01-01T10:30:08Z")

</div>

Can you copy the code used to push your data?

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [January 1, 2018, 11:21pm UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/19 "2018-01-01T23:21:14Z")

</div>

Hey @Francis.duhaut,

Our publishing app is derivative of this repository: [https://github.com/mangOH/RedSensorToCloud](https://github.com/mangOH/RedSensorToCloud). The only change we made is some retries in the `AvSessionStateHandler` callback.

---

<div class="post-metadata">

**Author:** ![Francis.duhaut](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/francis.duhaut/32/350_2.png) [@Francis.duhaut](https://mangoh.discourse.group/u/Francis.duhaut)\
**Post date:** [January 2, 2018, 12:05am UTC](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043/20 "2018-01-02T00:05:18Z")

</div>

Try to remove your retry in the Handler  
How is set the hearbeat on the system (frequency) ? Try with a Hearbeat set to 01H without retry

[Next page](https://mangoh.discourse.group/t/ensuring-reliable-cell-connection-and-retrying/1043.md?page=2)
