OpenEMS Backend - Session is terminated (Authentication failed) after a while


i´m having trouble to keep signed in on the openems backend ui. My setup is following

OpenEMS Backend: (Runs on HyperV)

Nginx Configuration - I think there I have an error:

OpenEMS Edge (Runs on raspberry pi):

Edge and Backend can successfully be connected together.

But after some time playing around in the UI of the Openems Backend I´m getting a authentication failed request. I can see this also in the Log of the backend

mon.websocket.OnRequestHandler] [Ui.Websocket] JSON-RPC Error "Authentication failed" for Request {"method":"authenticateWithToken","params":{"token":"bf7f7>

Logs on the edge side look like this.

What am I missing?

I did read this topic Error when connecting the edge to backend - #9 by stefan.feilmeier but it is still logging me out

I suspect that the changes introduced in this PR:

may have enhanced the connection speed and channel transmission, but they seem to have inadvertently affected the authentication process or the stability of the connection.

Could you please revert this PR locally and check if it resolves the issue?

Interestingly, the error appears to occur sporadically.

Maybe you cold Debug some things to see where the Error Originates from so we can keep the Improvements and “delete” the Errors :smiley: ?

@stefan.feilmeier, just letting you know.

Best regards!

1 Like

I´m running on my own fork where this commit does not exist. Comparing Rayleigh3105:production_meter...OpenEMS:develop · Rayleigh3105/openems · GitHub

I´m will sync my fork and check if it is still happening.


1 Like

In both versions there is exactly the same behavior. After getting the log the user is thrown out of openems via the UI on the backend. The “authentication” on the edge site is working as expected.

Apr 24 14:02:08 linux1 java[25236]: 2024-04-24T14:02:08,829 [socket-1] WARN [mon.websocket.OnRequestHandler] [Ui.Websocket] JSON-RPC Error "Authentication >

1 Like

Okay, I am glad that the PR is NOT the issue… :slight_smile:

Strange, that i have the same Issues without a Metadata Dummy but with actual Backend Provider

1 Like

Maybe we can enclose the problem. Do you know a version of OpenEMS where the session management or authentication worked for sure?

Should be the 2024.3.0

Can´t get this version working.

16:56:06.995 [FelixDispatchQueue] ERROR Events.Framework - FrameworkEvent ERROR org.osgi.framework.BundleException: Unable to resolve io.openems.shared.influxdb [24](R 24.0): missing requirement [io.openems.shared.influxdb [24](R 24.0)] osgi.wiring.package; (&(>=33.1.0)(!(version>=34.0.0))) Unresolved requirements: [[io.openems.shared.influxdb [24](R 24.0)] osgi.wiring.package; (&(>=33.1.0)(!(version>=34.0.0)))]

I will have another try tomorrow.

Use a precompiled version for testing

I have the Backend now running with version 2024.3.0, but the behaviour is still the same. My edge is still running on my fork.

On the edge site I´m getting logs like these.
Disconnected from OpenEMS Backend [ws://192.168.x.x:8081]

[ctrlBackend0] Connected WebSocket successfully [0s]
[ctrlBackend0] # Connect Blocking [100]... done
[ctrlBackend0] Connected to OpenEMS Backend
[ctrlBackend0] # Reset WebSocket Client... done
[ctrlBackend0] # Reset WebSocket Client...
[ctrlBackend0] Unable to send JSON-RPC message. WebsocketNotConnectedException:"jsonrpc":"2.0","method":"timestampedData","params":{"1714027986000":{"_sum/ConsumptionActiveEne...
[ctrlBackend0] Connecting WebSocket... [CLOSED]
[ctrlBackend0] Waiting till next WebSocket reconnect [1s]

I think every time when the edge as no connection to the backend … the user gets thrown out in the backend UI.

I now have the backend and edge running on version 2024.3.0, unfortunately the behavior is still the same

After some research I still dont have a clue why the backend is doing this.

Log on Backend:

Apr 29 19:48:18 linux1 java[1544]: 2024-04-29T19:48:18,212 [hread #5] INFO  [socket.AbstractWebsocketServer] [Edge.Websocket] Starting websocket server [port=8081]
Apr 29 19:48:18 linux1 java[1544]: 2024-04-29T19:48:18,214 [hread #5] INFO  [socket.AbstractWebsocketServer] [Ui.Websocket] Starting websocket server [port=8082]
Apr 29 19:48:18 linux1 java[1544]: 2024-04-29T19:48:18,974 [socket-1] WARN  [mon.websocket.OnRequestHandler] [Ui.Websocket] JSON-RPC Error "Authentication failed" for Request {"method":"authenticateWithToken","params":{"token":"be7e0603-0fd6-435c-9909-2d955365055f"}}

Log on Edge device at the same time:

Apr 29 21:48:04 raspberrypi-3 java[52367]: 2024-04-29T21:48:04,550 [Worker-0] INFO  [ackend.SendChannelValuesWorker] [ctrlBackend0] Sending [18 values]: {ess1/DcDischargeEnergy=66053, _sum/UnmanagedConsumptionActivePower=960, _sum/EssActiveDischargeEnergy=66053, ess1/ActivePower=922, ess1/ActiveDischargeEnergy=66053, ess1/ActivePower=922, ess1/ActiveDischargeEnergy=66053, _sum/EssDischargePower=922, _sum/ConsumptionActiveEnergy=305134}
Apr 29 21:48:04 raspberrypi-3 java[52367]: 2024-04-29T21:48:04,552 [Backend0] INFO  [socket.ClientReconnectorWorker] [ctrlBackend0] Waiting till next WebSocket reconnect [3s]
Apr 29 21:48:04 raspberrypi-3 java[52367]: 2024-04-29T21:48:04,552 [Worker-0] WARN  [socket.AbstractWebsocketClient] [ctrlBackend0] Unable to send JSON-RPC message. WebsocketNotConnectedException: {"jsonrpc":"2.0","method":"timestampemessage. WebsocketNotConnectedException: {"jsonrpc":"2.0","method":"timestampedData","params":{"1714420084000":{"_sum/ConsumptionActiveEne...

Steps to reproduce:

  1. Login into backend via UI
  2. Select the connected edge device
  3. Do something there (History tab/Settings)

Does somebody else have this kind of problems with edge and backend connection?

I found my Problem. The setup with the backend was wrong I did it with this file and changed it all to backend specific things.
OpenEMS_Deployment.pdf (138.4 KB)

After following Deploy OpenEMS Backend :: Open Energy Management System the setup with Edge and backend connection works great.

1 Like