I recently installed the emoncms software on a new VPS server running Ubuntu 12.10 and MySQL 5.5.27-0ubuntu2. I have a NanodeRF sending data to it with the code modified from the latest to send /input/post.json? rather than /api/post.json? which no longer seems to work.
From a completely fresh install of both the emoncms software and a MySQL database, after the Nanode has sent a few data posts, I start to receive an 'OK' and the inputs appear on the input page. So far so good.
A few data sends later, and I start to get the following on the Input Configuration page:
"We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/emoncms/Modules/feed/feed_model.php on line 138"
"Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/emoncms/Modules/feed/feed_model.php on line 138"
So I start to check out the time request from the nanodeRF and the response of the server. Here is what the Nanode is sending (I modified the code to send the message to the USB monitor):
Time request sent: /input/local.json?apikey=myapikeydisguised....edca15ce0ce7b37678da3
If I try this direct in the browser as follows:
http://emoncms.omniation.com/input/local.json?apikey=myapikeydisguised.....
I get the following response:
false
If I send the message using /api/local.json? instead of /input/local.json? I get ""
My thinking is that somehow my server is not providing the system time to the emoncms software for some reason and it's getting upset. The activity in the database suggests that it is storing the data, but that the software refuses to display it because the timestamp is invalid.
Does anyone have any ideas how I might sort it out? Many thanks. Richard
Re: emoncms time issue
sudo dpkg-reconfigure tzdata
and choose the correct time zone
Re: emoncms time issue
Thank you madmat.
Did that setting it to GMT. DROPed the dB and re-created it. Same symptoms! :(
Re: emoncms time issue
Actually, that's not quite true. I am only getting the first message now:
"We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/emoncms/Modules/feed/feed_model.php on line 138"
not the more extensive second message. However, I still have no feeds on the feed page even though I have configured them.
Re: emoncms time issue
Hmm, you should turn off error report printing in the browser by editing your php.ini or by adding
A call to error_reporting in /var/www/emoncms/index.php like
error_reporting(0);
Also if you want to post some data to your emoncms instance you should use
/emoncms/input/post.json as an url, with the appropriate parameters (apikey,nodeid and values)
You can look at an example on your emoncms instance, input tab api help ... I can't say whether your url is correct as it got truncated (at least on my tablet....)
Re: emoncms time issue
Hi matt,
Thank you for your advice. Posting of data is as per the code in git for the NanodeRF_multinode (apart from the change from /api/ to /input/) and consistent with the input tab api help and works initially, with the emoncms returning an 'OK' for the first few sends to a newly initialised database. After the first few sends to a newly initialised database, the emoncms software is refusing to display the data or return an 'OK' acknowledgement because it thinks that either the timestamp in the database, or the timezone, or both, is invalid.
Regards, Richard
Re: emoncms time issue
I find it really weird that the server side works for 'a few sends' and then starts issuing warnings without anything changing .. could you please post (without the apikey) an apache (or nanode serial) log of the calls that work and another of the ones that give you the error ?
Also, do you realise that the code in the nanode posts to /<path>/post.json while you have posted urls using /<path>/local.json ?
If you use anything other than post.json or bulk.json for the input you will indeed get
false
as a response
Re: emoncms time issue
Hi matt,
Spooky isn't it? See attached log. Remember that I am starting with a completely clean database when I do this.
I now realise that the point at which it changes from successful posts to failing posts is the exact time at which I create the first 'Log to feed' process in the Input Configuration for the first channel.
P.S. Don't worry about the visibility of the apikey as I have dropped and recreated the dB which automatically gives it a new key. Yes, I have to re-program the NonodeRF each time I do this to make it work again but this takes seconds.
Thank you for your time and attention. Richard
Re: emoncms time issue
Ok ... That makes a lot more sense .... Did you try to disable error reporting? Or even better, just add a line in /var/www/emoncms/index.php :
date_default_timezone_set("GMT") ;
and see whether it solves the problem with the warning...
Re: emoncms time issue
Hi matt,
I will try disabling error reporting, but, because I suspect that it has something to do with the Ubuntu installation, first I'm going to try installing it on a CentOS 6 VPS to see if I get the same problem. Will let you know what happens for both.
Thank you for your continued interest. Richard
Re: emoncms time issue
Hi,
unless you change how php is set to display (or not) errors and warnings in the browser changing distribution won't really change the result
In the standard emoncms sd card image, this is the relevant setting:
/etc/php5/apache2/php.ini
...
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = Off
....
Unless you apply the same setting on whatever apache instance you create you will have to either disable the warnings locally (previously I suggested editing index.php, but probably editing settings.php would be better) or understand why the warning is being issued and make it go away by setting the correct timezone
Re: emoncms time issue
Thanks matt,
I am having other issues on CentOS so will follow your advice and let you know the result.
Regards, Richard
Re: emoncms time issue
Done. Same problem. I just don't see the error on the page. I'm going to have to delve a bit deeper into the code I think.
Re: emoncms time issue
Hmm, can't really help then ... without access to the system i can't tell what's going wrong ... And can't reproduce it on my local server ....
Let us know what you find out....
Re: emoncms time issue
Uh oh. The error messages are back! I have checked /etc/php5/apache2/php.ini again and it definitely contains:
display_errors Off
in the appropriate place. I have also done another
# service apache2 restart
for good measure. Interestingly I can get the messages from the NanodeRF working again by deleting the process in the Input configuration page that is causing the errors. If the process is one that logs, e.g. 'Log to feed' or 'Power to kWh', then it wrecks the messages. If it just manipulates the data, e.g. 'x 2', then it doesn't.
I'm beginning to wonder if I have set up the MySQL properly. I have created a MySQL user as follows:
mysql> CREATE USER 'emoncms'@'localhost' IDENTIFIED BY 'xxxxxxxxxx';
mysql> GRANT ALL ON emoncms.* TO 'emoncms'@'localhost' IDENTIFIED BY 'xxxxxxxxxx';
Is the 'emoncms.*' correct? The emoncms software doesn't seem to complain and mysql doesn't like 'emoncms' without the '.*'
The settings.php file contains:
$username = "emoncms";
$password = "xxxxxxxxxx";
$server = "localhost";
$database = "emoncms";
Re: emoncms time issue
Success!
I had to do the following in settings.php:
// Error processing
$display_errors = FALSE;
I now have working feeds and working messages. Thank you matt. Got there in the end.