WebSocket
Chargers connect to Capacitor via WebSocket using the OCPP 1.6J protocol. The connection is established automatically when the charger is configured with the correct URL.
Connection endpoint
WebSocket URL
text
wss://capacitor.live/ocpp/:chargeBoxId
Example: wss://capacitor.live/ocpp/CHARGER-001
Connection requirements
- Charger must be registered via the REST API first
- WebSocket path must include the registered
chargeBoxId - Protocol:
ocpp1.6(subprotocol negotiation) - Connection is validated before the WebSocket upgrade
Unregistered chargers will be rejected at the WebSocket handshake. Register the charger via
POST /api/v1/chargers first.Charger → Capacitor
OCPP messages sent by the charger to the backend:
| Message | Description |
|---|---|
BootNotification | Charger announces itself on first connection |
Heartbeat | Periodic keep-alive (default every 300s) |
StatusNotification | Connector status change |
Authorize | Validate an idTag before starting |
StartTransaction | Charging session has started |
StopTransaction | Charging session has ended |
MeterValues | Energy meter readings during session |
FirmwareStatusNotification | Firmware update progress |
DiagnosticsStatusNotification | Diagnostics upload progress |
Capacitor → Charger
Commands sent from the backend to the charger (triggered via REST API):
| Command | API Endpoint |
|---|---|
RemoteStartTransaction | POST /chargers/:id/remote-start |
RemoteStopTransaction | POST /transactions/:id/stop |
Reset | POST /chargers/:id/reset |
UnlockConnector | POST /chargers/:id/unlock |
ClearCache | POST /chargers/:id/cache/clear |
TriggerMessage | POST /chargers/:id/trigger |
ChangeAvailability | POST /chargers/:id/availability |
GetConfiguration | POST /chargers/:id/configuration/get |
ChangeConfiguration | POST /chargers/:id/configuration/change |
UpdateFirmware | POST /chargers/:id/firmware/update |
GetDiagnostics | POST /chargers/:id/diagnostics |
OCPP message format
OCPP 1.6J uses JSON-RPC over WebSocket. Messages have three types:
Call (request)
json
[2, "unique-id-123", "RemoteStartTransaction", {"connectorId": 1,"idTag": "USER001"}]
CallResult (response)
json
[3, "unique-id-123", {"status": "Accepted"}]
CallError (error)
json
[4, "unique-id-123", "InternalError", "Something went wrong", {}]