Imp communications issue

I have an impee in development that’s job is to read a tank level every hour then go back to sleep. The imp appears to always wake up correctly, but at times it doesn’t run expectedly. I have a local led arrangement to tell exactly where in the local code the imp has processed to. From what I can tell the Imp is running all the code correctly.
But the server logs seem to vary as to how far they report the IMP got to, also the agent isn’t run at times to insert the readings into a DB.

I am not in release 25 beta, but would be happy to be :slight_smile:

Here are the logs from last night
1, 7, 9 O’clock are ok
5, 6, 8 O’clock vary in how they behave
The Agent send line indicates that an entry was written to the database, there are no entries for the failed hours.
The 200 line is the web web server response written by the agent.

Tue Jul 09 2013 01:00:11 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 01:00:11 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 01:00:12 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 01:00:12 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 01:00:12 GMT+1000 (AUS Eastern Standard Time): Powering up.
Tue Jul 09 2013 01:00:12 GMT+1000 (AUS Eastern Standard Time): Reading
Tue Jul 09 2013 01:00:13 GMT+1000 (AUS Eastern Standard Time): Agent Send: (null : 0x0x0)
Tue Jul 09 2013 01:00:13 GMT+1000 (AUS Eastern Standard Time): Signal Strength: -53 Level: 39.4778 Volts:8.13016
Tue Jul 09 2013 01:00:13 GMT+1000 (AUS Eastern Standard Time): Powering down
Tue Jul 09 2013 01:00:14 GMT+1000 (AUS Eastern Standard Time): sleeping until 1373299204000
Tue Jul 09 2013 01:00:14 GMT+1000 (AUS Eastern Standard Time): Power state: online=>asleep
Tue Jul 09 2013 01:00:14 GMT+1000 (AUS Eastern Standard Time): 200
Tue Jul 09 2013 05:00:19 GMT+1000 (AUS Eastern Standard Time): Power state: asleep=>offline
Tue Jul 09 2013 05:00:44 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 05:00:44 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 05:00:46 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 05:00:46 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 05:01:06 GMT+1000 (AUS Eastern Standard Time): Power state: online=>offline
Tue Jul 09 2013 06:00:18 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 06:00:18 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 06:00:18 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 06:00:18 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 06:00:20 GMT+1000 (AUS Eastern Standard Time): Powering up.
Tue Jul 09 2013 06:00:38 GMT+1000 (AUS Eastern Standard Time): Power state: online=>offline
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Powering up.
Tue Jul 09 2013 07:00:09 GMT+1000 (AUS Eastern Standard Time): Reading
Tue Jul 09 2013 07:00:10 GMT+1000 (AUS Eastern Standard Time): Agent Send: (null : 0x0x0)
Tue Jul 09 2013 07:00:10 GMT+1000 (AUS Eastern Standard Time): Signal Strength: -56 Level: 38.4082 Volts:7.97962
Tue Jul 09 2013 07:00:10 GMT+1000 (AUS Eastern Standard Time): Powering down
Tue Jul 09 2013 07:00:10 GMT+1000 (AUS Eastern Standard Time): sleeping until 1373320804000
Tue Jul 09 2013 07:00:10 GMT+1000 (AUS Eastern Standard Time): Power state: online=>asleep
Tue Jul 09 2013 07:00:11 GMT+1000 (AUS Eastern Standard Time): 200
Tue Jul 09 2013 08:00:11 GMT+1000 (AUS Eastern Standard Time): Power state: asleep=>online
Tue Jul 09 2013 08:00:41 GMT+1000 (AUS Eastern Standard Time): Power state: online=>offline
Tue Jul 09 2013 08:01:00 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 08:01:00 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 08:01:01 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 08:01:02 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 08:01:21 GMT+1000 (AUS Eastern Standard Time): Power state: online=>offline
Tue Jul 09 2013 09:00:09 GMT+1000 (AUS Eastern Standard Time): Power state: offline=>online
Tue Jul 09 2013 09:00:09 GMT+1000 (AUS Eastern Standard Time): Device booting
Tue Jul 09 2013 09:00:09 GMT+1000 (AUS Eastern Standard Time): Device configured.
Tue Jul 09 2013 09:00:09 GMT+1000 (AUS Eastern Standard Time): Still old version! the index ‘getsoftwareversion’ does not exist
Tue Jul 09 2013 09:00:09 GMT+1000 (AUS Eastern Standard Time): Powering up.
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): Reading
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): Agent Send: (null : 0x0x0)
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): Signal Strength: -54 Level: 38.6684 Volts:7.99811
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): Powering down
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): sleeping until 1373328004000
Tue Jul 09 2013 09:00:10 GMT+1000 (AUS Eastern Standard Time): Power state: online=>asleep
Tue Jul 09 2013 09:00:11 GMT+1000 (AUS Eastern Standard Time): 200

Any advice would be appreciated.

I should note that I have omitted all the other successful runs to keep it shorter

Can you post at least part of the code? It seems like the data isn’t being flushed on the way into sleep, maybe? You’re not getting “the sleeping until” or the data before that, and the server is timing you out after you’ve gone to sleep.

Hey Hugo,

Key parts of the code

..
sendData(level, volts); 
server.log("Signal Strength: " + imp.rssi() + " Level: " + level + " Volts:" + volts);
...
imp.onidle(function() {
        server.sleepfor(sleepTime - (time() % sleepTime)); 
});

function sendData(level, volts)

local response = agent.send(“SendToHome”, “{“Level”:” + level + “, “SupplyVoltage”:”+ volts + “, “rssi”:” + imp.rssi() + “}”);
server.log("Agent Send: " + response);

As you can see from the logs, it varies as to when the server stops reporting activity,
If the server logs stop before the agent send is performed, the agent send always fails. This is why have called this a communications issue.
I can prove that the locally running code is executing all the way to completion.

Thanks for your interest

An update, last night the impee ran perfectly and provided readings every hour. There are still the odd entries in the logs where the server reports online -> offline. But it wakes correctly on time.

I’ve queued 25 for imp mac ending in 14e8, the other one you have is already running 25.

Is your internet connection particularly slow? Cellular maybe? Server.sleepfor does flush the connection, but with a fairly short timeout; maybe add server.flush(5); before server.sleepfor() and see if that helps.

Thanks for that.

We run ADSL, typically 2-7Mbps on average. Will try increasing timeout.
Will changing setsendtimeoutpolicy to WAIT_FOR_ACK help? (when I get 25 of course)

It will help with the data coming out of the imp, but not the sleep call (ie where it tells the server it’ll be gone for a while) as that has a fixed timeout.

However, DSL should be no problem at all. Very strange.

It’s now behaving exactly as I would expect. I have implemented the increased flush time and sendtimeout policy changes.

Thanks for your help.