A 1 or 2 way ocpp proxy with alert system on ChargePoint events
10K+
WebSocket OCPP proxy that forwards charge point traffic to one or two upstream OCPP servers, with an optional alert system for connection events and StatusNotification messages.
CALL, CALLRESULT, CALLERROR).CALL messages are forwarded to all connected upstreams.CALLs.CALL messages directly to the client.clientIdToHuman.json).npm install
or by Docker deployment
Edit config/config.json with your URLs and settings.
Run the proxy:
node src/index.js
| Key | Required | Description |
|---|---|---|
proxy.host | ✔ | Proxy listening address (e.g. 0.0.0.0) |
proxy.port | ✔ | Proxy listening port (e.g. 9000) |
primaryUrl | ✔ | Primary upstream WebSocket URL |
secondaryUrl | Secondary upstream WebSocket URL | |
logLevel | Log level: error, warn, info, debug |
The client must connect to a path of the form ws://<host>:<port>/<clientId> where <clientId> is an alphanumeric string (letters, digits, underscores, hyphen). Any connection with an invalid path is rejected immediately.
The proxy then opens an upstream connection to <primaryUrl><clientId> (and <secondaryUrl><clientId> if configured).
The file config/clientIdToHuman.json maps a technical client ID to a display name used in notifications:
{
"STATION01": "North Parking — Charger 1",
"STATION02": "South Parking — Charger 2"
}
If the file is missing or a given ID is not listed, the raw client ID is used.
Notifications are controlled by the notify object. Each event is enabled individually by setting its value to true.
| Key | Triggered when |
|---|---|
connectedToProxy | A client connects to the proxy |
disconnectedFromProxy | A client disconnects from the proxy |
connectedToUpstream | The proxy connects to an upstream |
disconnectedFromUpstream | The proxy disconnects from an upstream |
cpStatusAvailable | Charge point becomes Available (connectorId=0) |
cpStatusUnavailable | Charge point becomes Unavailable (connectorId=0) |
cpStatusFaulted | Charge point becomes Faulted (connectorId=0) |
conStatusAvailable | A connector becomes Available |
conStatusPreparing | A connector becomes Preparing |
conStatusCharging | A connector becomes Charging |
conStatusSuspendedEVSE | A connector becomes SuspendedEVSE |
conStatusSuspendedEV | A connector becomes SuspendedEV |
conStatusFinishing | A connector becomes Finishing |
conStatusReserved | A connector becomes Reserved |
conStatusUnavailable | A connector becomes Unavailable |
conStatusFaulted | A connector becomes Faulted |
conStartTransaction | A StartTransaction is received on a connector |
conStopTransaction | A StopTransaction is received on a connector |
To enable email and/or Pushover, add the corresponding blocks inside notify:
{
"notify": {
"connectedToProxy": true,
"cpStatusFaulted": true,
"email": {
"from": "[email protected]",
"to": "[email protected]",
"transporter": {
"host": "smtp.example.com",
"port": 587,
"secure": false,
"auth": { "user": "smtp-user", "pass": "smtp-pass" }
}
},
"pushover": {
"userKey": "YOUR_USER_KEY",
"appToken": "YOUR_APP_TOKEN"
}
}
}
If a channel is missing or misconfigured, it is disabled at startup and a warning is logged.
Email is sent via Nodemailer. The email.transporter object must follow the same format as the argument to nodemailer.createTransport({}).
{
"logLevel": "info",
"primaryUrl": "ws://ws1.ocpp.fr/",
"secondaryUrl": "ws://ws2.ocpp.fr/",
"proxy": { "host": "0.0.0.0", "port": 9000 },
"notify": {
"connectedToProxy": false,
"disconnectedFromProxy": false,
"connectedToUpstream": false,
"disconnectedFromUpstream": false,
"cpStatusAvailable": false,
"cpStatusUnavailable": false,
"cpStatusFaulted": true,
"conStatusAvailable": false,
"conStatusPreparing": false,
"conStatusCharging": true,
"conStatusSuspendedEVSE": false,
"conStatusSuspendedEV": false,
"conStatusFinishing": false,
"conStatusReserved": false,
"conStatusUnavailable": false,
"conStatusFaulted": true,
"conStartTransaction": true,
"conStopTransaction": true,
"email": {
"from": "[email protected]",
"to": "[email protected]",
"transporter": {
"service": "Gmail",
"auth": { "user": "smtp-user", "pass": "smtp-pass" }
}
},
"pushover": {
"userKey": "YOUR_USER_KEY",
"appToken": "YOUR_APP_TOKEN"
}
}
}
node src/index.js
Graceful shutdown on SIGINT / SIGTERM (all client and upstream connections are closed before exit).
Client (OCPP charge point)
│
▼
OcppProxy ──── OcppRouter (message routing, response filtering)
│
├──► UpstreamConnection PRI ──► Primary server
└──► UpstreamConnection SEC ──► Secondary server (optional)
| Component | File | Role |
|---|---|---|
OcppProxy | src/proxy.js | WebSocket server, client management and orchestration |
OcppRouter | src/ocpp-router.js | OCPP parsing, messageId tracking, response filtering |
UpstreamConnection | src/upstream.js | Upstream connection, automatic reconnection with backoff |
Notify | src/notify.js | Alert triggering and delivery (email / Pushover) |
Content type
Image
Digest
sha256:5dec41905…
Size
56.7 MB
Last updated
8 months ago
docker pull wocha/ocpp-proxy-alert