-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Session Management for Charge Point Connections #2908
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files@@ Coverage Diff @@
## develop #2908 +/- ##
=============================================
+ Coverage 56.63% 56.64% +0.01%
- Complexity 9513 9515 +2
=============================================
Files 2253 2253
Lines 96074 96074
Branches 7095 7095
=============================================
+ Hits 54401 54408 +7
+ Misses 39666 39658 -8
- Partials 2007 2008 +1 |
@Sn0w3y Thanks a lot! We'll give the provided patch a try.
This is absolutely true. Occasionally, we also experience erratic behavior, and it's sometimes difficult to determine if this is the cause, which can be quite frustrating. By the way, here’s the fix we implemented. It mostly resolved the issue, but we’re still experiencing some very rare instances of erratic behavior, which is troubling. From 342832e40892ae147dc020edd37d93fc297b52e1 Mon Sep 17 00:00:00 2001
From: Katsuya Oda <[email protected]>
Date: Wed, 4 Dec 2024 09:05:59 +0900
Subject: [PATCH] fix: remove previous session
---
.../src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java b/io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
index 66d4d78b3..e461755a2 100644
--- a/io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
+++ b/io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
@@ -90,7 +90,7 @@ public class MyJsonServer {
var ocppIdentifier = information.getIdentifier().replace("/", "");
- MyJsonServer.this.parent.ocppSessions.put(ocppIdentifier, sessionIndex);
+ var sessionIndexPrevious = MyJsonServer.this.parent.ocppSessions.put(ocppIdentifier, sessionIndex);
var presentEvcss = MyJsonServer.this.parent.ocppEvcss.get(ocppIdentifier);
@@ -103,6 +103,10 @@ public class MyJsonServer {
evcs.newSession(MyJsonServer.this.parent, sessionIndex);
MyJsonServer.this.sendInitialRequests(sessionIndex, evcs);
}
+
+ if (sessionIndexPrevious != null) {
+ MyJsonServer.this.parent.activeEvcsSessions.remove(sessionIndexPrevious);
+ }
}
@Override
--
2.39.5 (Apple Git-154) |
@katsuya Thank you for your efforts in addressing the session management issue aswell! Greetings |
io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/EvcsOcppServer.java
Show resolved
Hide resolved
io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
Show resolved
Hide resolved
io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
Show resolved
Hide resolved
io.openems.edge.evcs.ocpp.server/src/io/openems/edge/evcs/ocpp/server/MyJsonServer.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sn0w3y It seems that the fix for the following issue has been removed and replaced with the changes from #2912. Was this intentional? Since the root causes are different, I think it would be better to address them separately.
When a new connection is established, the old connection must be correctly removed from activeEvcSessions.
5d3f2d5
to
25e7484
Compare
@katsuya you are invited to do the WIP please :) |
Summary
This PR addresses the issue of improper session management when multiple connections are established to the same charge point. Specifically, it ensures that only one active session per charge point is maintained, and existing sessions are properly terminated before establishing new ones. This update helps prevent unintended side effects where disconnecting an older connection impacts newer connections.
Changes Made
Handle Existing Sessions When a New Connection is Established
newSession
method inMyJsonServer.java
:lostSession()
and removes it from active sessions.Prevent
lostSession
from Affecting New ConnectionslostSession
method inMyJsonServer.java
:ocppSessions
, it verifies that the session being disconnected is still the active one.Ensure Proper Cleanup in
removeEvcs
removeEvcs
method inEvcsOcppServer.java
:lostSession()
for cleanup.Additional Enhancements
activeEvcsSessions
andocppSessions
are accessed in a thread-safe manner.Testing
OCPP server fail to send commands to the charging stations when two connections are established #2906
Motivation
These changes address the observed problem where OpenEMS failed to handle multiple simultaneous connections to the same charge point, causing instability in session management. By implementing these changes, the system will now correctly manage and isolate sessions, ensuring reliable operation of charge point connections.
Related Issues
Notes
If further refinements are needed, or any issues persist with session handling, please feel free to provide feedback.