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

  1. Charger must be registered via the REST API first
  2. WebSocket path must include the registered chargeBoxId
  3. Protocol: ocpp1.6 (subprotocol negotiation)
  4. 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:

MessageDescription
BootNotificationCharger announces itself on first connection
HeartbeatPeriodic keep-alive (default every 300s)
StatusNotificationConnector status change
AuthorizeValidate an idTag before starting
StartTransactionCharging session has started
StopTransactionCharging session has ended
MeterValuesEnergy meter readings during session
FirmwareStatusNotificationFirmware update progress
DiagnosticsStatusNotificationDiagnostics upload progress

Capacitor → Charger

Commands sent from the backend to the charger (triggered via REST API):

CommandAPI Endpoint
RemoteStartTransactionPOST /chargers/:id/remote-start
RemoteStopTransactionPOST /transactions/:id/stop
ResetPOST /chargers/:id/reset
UnlockConnectorPOST /chargers/:id/unlock
ClearCachePOST /chargers/:id/cache/clear
TriggerMessagePOST /chargers/:id/trigger
ChangeAvailabilityPOST /chargers/:id/availability
GetConfigurationPOST /chargers/:id/configuration/get
ChangeConfigurationPOST /chargers/:id/configuration/change
UpdateFirmwarePOST /chargers/:id/firmware/update
GetDiagnosticsPOST /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", {}]