Uploads "failing" to AWEKAS and my local EmonCMS server

125 views
Skip to first unread message

wwwd...@gmail.com

unread,
Feb 16, 2023, 4:58:41 PM2/16/23
to weewx-user
I was going through my logs and noticed that weewx is logging upload failures to both my local EmonCMS server and AWEKAS. But the thing is, the data in both of those is fresh. Does anyone have any ideas what could cause it to throw an error but still upload the data?

Feb 16 13:55:25 weather weewx[2305507] ERROR weewx.restx: EmonCMS: Failed to publish record 2023-02-16 13:55:00 PST (1676584500): Failed upload after 3 tries
Feb 16 13:55:27 weather weewx[2305507] ERROR weewx.restx: AWEKAS: Failed to publish record 2023-02-16 13:55:00 PST (1676584500): Failed upload after 3 tries

Tom Keffer

unread,
Feb 16, 2023, 6:57:50 PM2/16/23
to weewx...@googlegroups.com
If you set debug=1 in weewx.conf, then restart, it will give you more information in the system log about the failure modes.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/aa31d711-1ad7-44e6-bdab-60c2992ba5c1n%40googlegroups.com.

wwwd...@gmail.com

unread,
Feb 16, 2023, 8:14:08 PM2/16/23
to weewx-user
Thanks for the debug tip. But I'm not sure which is worse... that AWEKAS is now logging success, or that EmonCMS isn't telling me much of anything:
Feb 16 17:00:16 weather weewx[2314849] INFO weewx.restx: AWEKAS: Published record 2023-02-16 17:00:00 PST (1676595600)
Feb 16 17:05:26 weather weewx[2314849] DEBUG weewx.restx: AWEKAS: Failed upload attempt 1: timed out
Feb 16 17:05:32 weather weewx[2314849] INFO weewx.restx: AWEKAS: Published record 2023-02-16 17:05:00 PST (1676595900)


Feb 16 17:05:16 weather weewx[2314849] DEBUG weewx.restx: EmonCMS: Failed upload attempt 1: Server returned 'b'ok''
Feb 16 17:05:21 weather weewx[2314849] DEBUG weewx.restx: EmonCMS: Failed upload attempt 2: Server returned 'b'ok''
Feb 16 17:05:26 weather weewx[2314849] DEBUG weewx.restx: EmonCMS: Failed upload attempt 3: Server returned 'b'ok''
Feb 16 17:05:26 weather weewx[2314849] ERROR weewx.restx: EmonCMS: Failed to publish record 2023-02-16 17:05:00 PST (1676595900): Failed upload after 3 tries

I have to wonder if this is a problem with the way the plugin is checking the return value. I'll dig into the plugin code, it looks like it hasn't been updated in ages. 

Tom Keffer

unread,
Feb 16, 2023, 8:37:25 PM2/16/23
to weewx...@googlegroups.com
I would agree. The EmonCMS extension does not seem to be interpreting the return value correctly.


gjr80

unread,
Feb 16, 2023, 11:23:03 PM2/16/23
to weewx-user
Sounds like a classic python2/python3 string issue. I'm guessing that WeeWX is running under python3 and the EmonCMS was written for python2 ?. If so chances are EmonCMS is returning a byte string which python2 happily accepts as a string but python3 treats strings and bytestrings separately. You probably need to a .decode() call to the result the uploader obtains from EmonCMS.

Gary 

Tom Keffer

unread,
Feb 17, 2023, 7:17:00 AM2/17/23
to weewx...@googlegroups.com
Gary may be on to something. The current version of the uploader already does a decode(), yet the log shows a byte string.

Are you sure you're running the latest version of the uploader?

wwwd...@gmail.com

unread,
Feb 17, 2023, 3:43:21 PM2/17/23
to weewx-user
I think Gary has it right -- EmonCMS is ancient. https://github.com/matthewwall/weewx-emoncms. The last update was 3 years ago.

I did a python2 - 3 conversion on it ages ago, but I must have missed something that is finally coming back to haunt me.

It's not overly complicated code...  But if that 'ok' is coming back as bytes instead of a string, this comparison is going to fail.  
    def check_response(self, response):
        txt = response.read()
        if txt != 'ok' :
            raise weewx.restx.FailedPost("Server returned '%s'" % txt)

Tom Keffer

unread,
Feb 17, 2023, 5:09:56 PM2/17/23
to weewx...@googlegroups.com
I personally submitted a Pull Request two years ago to fix this problem: https://github.com/matthewwall/weewx-emoncms/pull/1/files

 If you have the current version, it should work. Unfortunately, in my PR, I did not update the version code, so you'll have to look at the actual code to see if you have the fix. You want to see 

    def check_response(self, response):
        txt = response.read().decode().lower()
        if txt != u'ok' :
 


wwwd...@gmail.com

unread,
Feb 18, 2023, 5:52:31 PM2/18/23
to weewx-user
Thanks Tom, that did the trick!

Feb 18 14:40:16 weather weewx[2429019] INFO weewx.restx: EmonCMS: Published record 2023-02-18 14:40:00 PST (1676760000)

Reply all
Reply to author
Forward
0 new messages