Skip to content

fix(ocpp): a charger socket may stay silent for five heartbeats - #1790

Merged
frahlg merged 1 commit into
masterfrom
fix/ocpp-read-wait
Oct 21, 2026
Merged

frahlg merged 1 commit into
masterfrom
fix/ocpp-read-wait

Conversation

@frahlg

@frahlg frahlg commented Oct 21, 2026

Copy link
Copy Markdown
Member

Problem

The end-to-end simulator run before the beta (scenario s0, idle OCPP charger) saw FTW close the charger's socket 20 ms after the charger's first heartbeat arrived, 60 s after connecting, in 2 of 3 runs. The charger reconnected after 5 s, and Home use showed "≈" for those seconds.

Cause: ocpp-go v0.19.0's ws.Server sets a read deadline of PingWait, 60 s by default, and resets it only after a handled message or a WebSocket ping (ws/websocket.go readPump). FTW never set it. An idle charger that sends nothing but heartbeats every 60 s, and no WebSocket pings, lands exactly on that edge. Before #1779 Core asked chargers for a 60 s heartbeat, so a compliant charger without pings raced the deadline on every heartbeat; #1779 asks for 30 s, which helps chargers that follow the interval but not those that keep their own 60 s.

Change

newListener sets PingWait to five heartbeat intervals (150 s with the default 30 s; 300 s if a site configures 60 s). It applies to the 1.6 and 2.0.1 listeners. The socket timer only has to outlast a few missed heartbeats; FTW's telemetry watchdog still decides when a quiet charger is offline. No setting added.

Test

TestSilentChargerSocketFollowsHeartbeat: with a 1 s heartbeat a silent charger's socket closes after 5.0 s. Without the change the socket stayed open for the test's whole 12 s (the 60 s default). make verify: 78 Go packages pass.

Not run in the simulator rig yet; the final pre-beta run on the release commit includes s0.

🤖 Generated with Claude Code

ocpp-go's server closes a socket that has sent nothing for PingWait,
60 s by default, and resets the timer only after a handled message or a
WebSocket ping. An idle charger that sends only heartbeats every 60 s
lands on that edge: the end-to-end simulator run on 21 October saw the
socket closed 20 ms after the first heartbeat arrived, in 2 of 3 runs,
followed by a reconnect and a few seconds of "≈" on Home use.

Set PingWait to five heartbeat intervals (150 s with the default 30 s).
The telemetry watchdog still decides when a quiet charger is offline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T16:42:42.418383Z 5eac4be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit db5aec8 into master Oct 21, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant