Although Emoncms V8 is now working ok for me on my Windows Home Server WAMP installation (login, inputs, feeds, graphs are all working), I get a lot of warnings and fatal errors in the apache.log. The reason is always in line 465 in PHPFiwa.php.
Sometimes WAMP (or apache?) stops working and then my Python script to read data from a Jeelink (and EmonTx) stops with an error mesage that apache is not responding.
Part of the error log:
[Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP Warning: unpack(): Type I: not enough input, need 4, have 0 in C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php on line 465 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP Stack trace: [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 1. {main}() C:\\wamp\\www\\emoncms\\index.php:0 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 2. controller() C:\\wamp\\www\\emoncms\\index.php:98 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 3. input_controller() C:\\wamp\\www\\emoncms\\core.php:66 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 4. Process->input() C:\\wamp\\www\\emoncms\\Modules\\input\\input_controller.php:249 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 5. Process->log_to_feed() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:90 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 6. Feed->insert_data() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:135 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 7. PHPFiwa->post() C:\\wamp\\www\\emoncms\\Modules\\feed\\feed_model.php:397 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 8. PHPFiwa->get_meta() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:102 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 9. unpack() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:465[Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 1. {main}() C:\\wamp\\www\\emoncms\\index.php:0 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 2. controller() C:\\wamp\\www\\emoncms\\index.php:98 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 3. input_controller() C:\\wamp\\www\\emoncms\\core.php:66 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 4. Process->input() C:\\wamp\\www\\emoncms\\Modules\\input\\input_controller.php:249 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 5. Process->log_to_feed() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:90 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 6. Feed->insert_data() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:135 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 7. PHPFiwa->post() C:\\wamp\\www\\emoncms\\Modules\\feed\\feed_model.php:397 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 8. PHPFiwa->get_meta() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:102 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 9. unpack() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:465 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 128450560 bytes) in C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php on line 465 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP Stack trace: [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 1. {main}() C:\\wamp\\www\\emoncms\\index.php:0 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 2. controller() C:\\wamp\\www\\emoncms\\index.php:98 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 3. input_controller() C:\\wamp\\www\\emoncms\\core.php:66 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 4. Process->input() C:\\wamp\\www\\emoncms\\Modules\\input\\input_controller.php:249 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 5. Process->log_to_feed() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:90 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 6. Feed->insert_data() C:\\wamp\\www\\emoncms\\Modules\\input\\process_model.php:135 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 7. PHPFiwa->post() C:\\wamp\\www\\emoncms\\Modules\\feed\\feed_model.php:397 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 8. PHPFiwa->get_meta() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:102 [Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP 9. unpack() C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php:465 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 128450560 bytes) in C:\wamp\www\emoncms\Modules\feed\engine\PHPFiwa.php on line 465
Does someone have a clue why this happens?
BR, Jörg.
PS: sorry, this formatted text is messing up the whole screen and overwrites the forum topics. Is there a way to show this decently?
PPS: after running Emoncms now for some days, my database file size is ~200kb per feed, but my apache_error.log is ~400Mb and the access.log ~50Mb. Is this 'healthy'?
Re: EmoncmsV8 WAMP apache error
Doesnt look particularly healthy, looks like its logging every function call, Can you turn off the logging, I would turn off both access logs and the php stack trace, should be possible from someware in your php or apache settings, that should sort the logging.
Would be good then to establish how often and why the Fatal error: Allowed memory size of 134217728 bytes exhausted error occurs.
Re: EmoncmsV8 WAMP apache error
Ok, have to find where I can turn off the logging.
The
errorwarning that comes most often is:[Wed Mar 26 08:24:36.052269 2014] [:error] [pid 7976:tid 1504] [client 127.0.0.1:63946] PHP Warning: unpack(): Type I: not enough input, need 4, have 0 in C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php on line 465
I have no clue what that means.
Re: EmoncmsV8 WAMP apache error
After another crash (?) of the server:
This warning:
[Wed Mar 26 22:58:12.788141 2014] [:error] [pid 2040:tid 1480] [client 127.0.0.1:64724] PHP Warning: unpack(): Type I: not enough input, need 4, have 0 in C:\\wamp\\www\\emoncms\\Modules\\feed\\engine\\PHPFiwa.php on line 465
seems to be the root cause for the crashes. Always after these events will the server stop working correctly. Sometimes with the fatal error shown above, this time with a hint:
[Thu Mar 27 01:04:26.931158 2014] [mpm_winnt:error] [pid 2040:tid 3480] AH00326: Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
Anyone with an idea what happens in line 465 of PHPFiwa.php? It seems that the .meta file has fewer entries (bytes) than expected. But I checked it and all .meta files in the PHPFiwa folder have 44 bytes.
Re: EmoncmsV8 WAMP apache error
A bit of background on what the unpack error means. Each datapoint in a PHPFiwa feed takes up 4 bytes, which is the length of a single float value, (timestamps are calculated from the start time recorded in the meta file and the datapoint position in the file). The unpack error saying not enough input means it tried to read a location that was either partially or fully off the end of the file which would have caused not enough bytes to be given to unpack.
So It sounds to me like you might have one feed that is somehow corrupt, or was never created properly in the first place. Can you see a feed in your feeds list that has no data in it?
Can you recreate that feed and see if the error goes away?
Re: EmoncmsV8 WAMP apache error
Ah, just looking at the code, line 465 is actually the meta file, which also suggests the feed was not initialized properly the first time it was created
Re: EmoncmsV8 WAMP apache error
This is what I thought. Can I debug somehow, which file name is causing this error (as I said already, I have no experience with Python, PHP and the like at all)?
Re: EmoncmsV8 WAMP apache error
And there is another warning now (have not seen that before):
This warning comes for all feeds (1.dat, 2.dat, 3.dat, 5.dat). Why does filesize(): stat fail? Has this something to do with using slashes instead of backslashes?
Re: EmoncmsV8 WAMP apache error
After deleting all feeds and creating them anew, I have exactly the same errors. I have then changed all feeds to PHPFINA and this works for me. File size is shown correctly and no error messages anymore. Very strange as the code for these two feed engines is nearly identical ( e.g for function get_feed_size() which seems to throw the warning in my last posting).
Is there any good reason why PHPFIWA does not work (for me)?
BR, Jörg.
Re: EmoncmsV8 WAMP apache error
Could it be a folder permissions related problem, are the permissions the same on both folders?
Re: EmoncmsV8 WAMP apache error
Yes, as far as I can say permission is exactly the same (I have simply set all permissions for all users). The files were also created correctly and the feed data was shown correctly in the graphs.
Re: EmoncmsV8 WAMP apache error
I'm currently posting in http://openenergymonitor.org/emon/node/4386 about my randomly broken "live" Pi. I've got the same symptoms (PHPFIWA doesn't work, PHPFINA is OK) on raspian.
It's a puzzler.
Re: EmoncmsV8 WAMP apache error
Preliminary work-around: it seems that restarting the rfm12piphp process allows the PHPFIWA feeds to be updated.
Re: EmoncmsV8 WAMP apache error
Dave,
my problem is a little bit different. For me the PHPFiwa feeds work as far as storing data is concerned and the data is also presented correctly in the graphs. But the size of the feeds is not shown correctly because the filesize() function returns with an error. Very strange.
Re: EmoncmsV8 WAMP apache error
Ah, OK. I also get the stat error, but I guess that's in addition to whatever my underlying problem is!
Re: EmoncmsV8 WAMP apache error
Did you perhaps relocate the directories for the feeds in settings.php into a non-default location? Then you might have to change the directory also in the PHPFiwa.php (and the others you use). I just found this by coincidence some days ago. One of the many small mistakes one can make ..... (and updating to a new version brings the same 'feature' up again and again).
Re: EmoncmsV8 WAMP apache error
Ah I've just found the problem with the getting the size of the phpfiwa feeds, i will push a fix up.
Re: EmoncmsV8 WAMP apache error
Fix has been uploaded v8.0.6
Re: EmoncmsV8 WAMP apache error
There's no dat file (without index number) for FIWA I'm guessing? :-)
Re: EmoncmsV8 WAMP apache error
no thats it :)
Re: EmoncmsV8 WAMP apache error
I'm getting a similar behavior with the phptimeseries
2014-12-18 13:29:07: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Warning: unpack(): Type x: not enough input, need 1, have 0 in /var/www/emoncms/Modules/feed/engine/PHPTimeSeries.php on line 248
PHP Warning: unpack(): Type x: not enough input, need 1, have 0 in /var/www/emoncms/Modules/feed/engine/PHPTimeSeries.php on line 248
My machine has rebooted and that means that it may have halted at the moment of writting into the feeds file and that it did not logged points for a certain period. Would any of those be a reason for the feed to become corrupt?
Is there an easy way to check through the MYD files if they are corrupt?
Cheers