Session duration best practices and missing notes during session close and open

I’m having an intermittent issue. I have the notecard running in continuous mode with immediate syncs. I currently have the session duration set to 24 hours (but I believe had the issue with no duration set). I also have 2 routes: One to Blynk and another which is a web.get which sends over a logEvent over to Blynk to have Blynk send me an email.

The Issue occurs when I send a note to notehub around the same time that the session close/open happens.

{“closed”:true,“why”:“notecard ended the session”}

{“opened”:true,“why”:“continuous connection mode; periodic inbound sync due”}

Sometimes if the note is added (and synced) what I believe to be in between the session close/open, it seems to queue the note and complete the process after the new session begins. Other times it will, for example, execute the route to Blynk successfully and miss the web.get route (i.e., it will update the Blynk UI/app and miss sending me an email).

Is there a session “best practices” document somewhere? Something that goes into the management of sessions?

Thanks,

Joe

Hi @scavoj ,

All web requests require a continuous and active connection to Notehub. If you try and execute one while there is no connection or while it’s resetting, it just won’t happen. I would recommend changing your logic to check for an active connection prior to executing the web.get for example with hub.status.

Rob

1 Like

Thanks, Rob. Is there a best duration setting for sessions? What would be the reason I would want to make the duration longer (or shorter)?

Thanks,

Joe

Hi @scavoj ,

You don’t need to set a session duration to reset your session. The benefit of setting one is that it lets you measure metrics like data usage and Notes synced on a consistent schedule. If you’re not tracking those metrics, you can omit that argument or reset it like so:

{
  "req": "hub.set",
  "duration": -1
}