“Session expired or invalid” after WiFi outage (Salesforce Trailhead)


#1

Hi Community,
I have connected the impExplorer™ Developer Kit with Salesforce using the agent code provided in the Salesforce Trailhead (see the link below). This basically works, but from time to time the agent gets disconnected and the log displays message “Session expired or invalid”. This usually happens after a restart from a power down or WiFi outage.

I need to go to the Electric imp console and reinitiate the authentication. Then it starts working until next break. It also happens that from time to time one device gets disconnected (I have 3 and 2 others are working).

Is it possible to modify the agent code so that the connection is reestablished automatically?

Agent code on github (I haven’t changed anything except for authentication credentials): https://raw.githubusercontent.com/electricimp/Salesforce/master/examples/SmartRefrigerator/SmartRefrigerator_ExplorerKit_Salesforce.agent.nut