EmonHubEmoncmsHTTPInterfacer API not working for remote feed

I have an EmonCMS running on a Rpi that feeds two standalone instances of EmonCMS. One is on my home LAN and works fine, and one is on a shared hosting server that was working fine. I moved the server instance to a new directory/URL and now I can’t get the feed to update.

The RPI doing the feeding gives this error:

2022-09-04 09:55:20,805 WARNING  emoncms_remotename emoncms_remotename couldn't send to server: 418 Client Error: reauthentication required for url: http://my.url.au//input/bulk.json

If I take the URL and replace E-M-O-N-C-M-S-A-P-I-K-E-Y with the R/W key and paste it into a browser things work just fine.

The EmonHub configuration is below, taken from the suggestion in Log emonPi remotely - doesn’t work for me again - #18 by TrystanLea

[[emoncms_remotename]]
Type = EmonHubEmoncmsHTTPInterfacer
[[[init_settings]]]
[[[runtimesettings]]]
pubchannels = ToRFM12,
subchannels = ToEmonCMS,
url = http://x.x.id.au/emoncms
apikey = ********************************
senddata = 1 # Enable sending data to Emoncms.org
sendstatus = 1 # Enable sending WAN IP to Emoncms.org MyIP > Emoncms - myip list
sendinterval= 30 # Bulk send interval to Emoncms.org in seconds

This is the redacted log:

2022-09-04 10:12:00,654 INFO     emoncms_local sending: http://192.168.x.x/emoncms//input/bulk.json? data=[[1662282699.7068021,8,1139,22,2.01324,0,245.55272,300,300,300,300,300,300,0,-64],[1662282709.6230373,8,1165,21,3.0198600000000004,0,245.4802,300,300,300,300,300,300,0,-64],[1662282719.534087,8,1157,21,5.0331,0,244.81715999999997,300,300,300,300,300,300,0,-65]]&sentat=1662282720&apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2022-09-04 10:12:00,663 DEBUG    emoncms_remote Buffer size: 7
2022-09-04 10:12:00,664 INFO     emoncms_remote sending: http://x.x.id.au/emoncms/input/bulk.json? data=[[1662282660.0958626,8,1018,21,3.0198600000000004,0,244.97256,300,300,300,300,300,300,0,-65],[1662282670.0219557,8,1015,22,1.00662,0,244.57888,300,300,300,300,300,300,0,-64],[1662282679.9273295,8,1022,21,3.0198600000000004,0,244.73427999999998,300,300,300,300,300,300,0,-64],[1662282689.800564,8,1682,20,5.0331,0,244.62032,300,300,300,300,300,300,0,-64],[1662282699.7068021,8,1139,22,2.01324,0,245.55272,300,300,300,300,300,300,0,-64],[1662282709.6230373,8,1165,21,3.0198600000000004,0,245.4802,300,300,300,300,300,300,0,-64],[1662282719.534087,8,1157,21,5.0331,0,244.81715999999997,300,300,300,300,300,300,0,-65]]&sentat=1662282720&apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2022-09-04 10:12:00,778 WARNING  emoncms_remote emoncms_remote couldn't send to server: 418 Client Error: reauthentication required for url: http://x.x.id.au/emoncms/input/bulk.json
2022-09-04 10:12:00,780 DEBUG    emoncms_local acknowledged receipt with 'ok' from http://192.168.x.x/emoncms/

The EmonPI is version 11.0.9 and the server version is also 11.0.9 (fresh Git download).

Putting a deliberate error in the API key doesn’t seem to make any difference. Is this possibly a mod_rewrite issue? The .htaccess file in /emoncms is the one that comes in from git. This is super confusing for me.

Any pointers appreciated.

[APIKey redacted - Moderator (RW) ]

Beware, if this is the same browser you are accessing the UI with, it will work (as that has done the authentication).

Try pasting into a fresh private window - does it work then?

What is the URL listed in the Input API help page (top right of the Inputs page)?

Yes, possible. There is a modified file as a PR in Git IIRC which fixed a different issue, but they may be related.

Hi Brian,

Yes, I was using a private window to avoid that issue.

I’ve tried to log in again to get the URL you asked for, but am now getting a different error. After filling in the username and password I get “Username or password empty” after clicking on “Login”.
Checking the log file reveals some oddities:

2022-09-05 21:00:32.995|INFO|rememberme_model.php|login
2022-09-05 21:00:32.995|INFO|rememberme_model.php|getCookieValues: not present for IP Address: 49.x.x.x

This is repeated, and there are also other IP addresses from around that world that give the cookie error. Thing is this is a new sub-domain that has never been linked to elsewhere, so goodness knows what’s happening. Might have to dig into the webserver access and error logs to see what the hits actually are.

Is there an easy way to see the PR to try and prototype the change?

Last thought, does the PHP in EmonCMS validate the modules that are enabled? I’ve changed the PHP on my shared hosting server from 7.3 to 7.4 and it did reset some options. Just wondering if there is something that the code requires that I haven’t enabled and it is silently failing. The normal install process doesn’t really work on a shared host, so I’ve done a git clone, put DB credentials into settings.ini and run it from there.

Dave.

Have you cleared your cache?

Yes, and unfortunately that didn’t work. I also tried a browser that’s never been to the site too. The message in the EmonCMS log is

2022-09-07 09:33:44.383|INFO|rememberme_model.php|login
2022-09-07 09:33:44.383|INFO|rememberme_model.php|getCookieValues: not present for IP Address: 49.x.x.x
1 Like