OCPP WS/WSS connection tester
test-ocpp connects to an OCPP central system (CSMS) as a charge point, over WebSocket Secure (wss://, TLS) or plain WebSocket (ws://), then:
- Negotiates the OCPP subprotocol (
ocpp1.6orocpp2.0.1) - Sends a
BootNotification - Sends a
Heartbeat
It prints every message sent and received, the negotiated subprotocol, and the TLS version and cipher (or TLS: none for ws://). It exits with 0 on success and 1 on failure.
Installation
Requires Python 3.9+. Install the test-ocpp command with pipx:
pipx install test-ocpp
Or into a virtual environment with pip:
python3 -m venv .venv
.venv/bin/pip install test-ocpp
.venv/bin/test-ocpp --help
Don't pip install against the system Python. On Debian/Ubuntu it fails with externally-managed-environment.
From a source checkout
git clone https://github.com/mortenmathiasen/test-ocpp.git
cd test-ocpp
python3 -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest
In a checkout, ./test-ocpp ... works like the installed test-ocpp ... without activating the venv: if websockets is missing, it restarts itself with .venv/bin/python. python -m test_ocpp ... also works wherever the package is installed.
Usage
test-ocpp URL CHARGE_POINT_ID [options]
The charge point ID is appended to the URL, so wss://host/ocpp + CP001 connects to wss://host/ocpp/CP001. A trailing slash on the base URL doesn't matter. If the server needs the URL to end in a slash (wss://host/ocpp/CP001/), add --trailing-slash.
TLS or no TLS
The URL scheme picks the transport: wss:// uses TLS and ws:// doesn't. If you leave out the scheme (csms.example.com/ocpp), test-ocpp uses wss://. --tls and --no-tls override the scheme, so you can switch transports without editing the URL. The certificate options (--cert, --key, --ca, --insecure) only apply with TLS. With ws:// they're ignored and test-ocpp prints a warning.
Port
The port can be any port from 1 to 65535. Put it in the URL (wss://host:8443/ocpp) or pass --port, which overrides any port in the URL. Without either, the port is 443 for wss:// and 80 for ws://.
| Option | Description |
|---|---|
--tls |
Connect with TLS (wss://), overriding the URL scheme |
--no-tls |
Connect without TLS (ws://), overriding the URL scheme |
--port PORT |
Server port, overriding any port in the URL |
--trailing-slash |
End the URL with / after the charge point ID |
--ocpp {1.6,2.0.1} |
OCPP version (default 1.6) |
--username USER |
Basic auth username (default: the charge point ID). On its own, sends an empty password |
--password PASS |
Basic auth password (security profile 1/2) |
--cert FILE |
Client certificate PEM (security profile 3) |
--key FILE |
Client private key PEM |
--ca FILE |
CA bundle used to verify the server certificate |
--insecure |
Skip server certificate verification |
--vendor NAME |
Vendor sent in BootNotification (default TestVendor) |
--model NAME |
Model sent in BootNotification (default TestModel) |
--timeout SECONDS |
Connect and response timeout (default 15) |
Examples
OCPP 1.6 connection without authentication. With neither --username nor --password, no Authorization header is sent:
test-ocpp wss://csms.example.com/ocpp CP001
Non-standard port, either in the URL or with --port:
test-ocpp wss://csms.example.com:8443/ocpp CP001
test-ocpp wss://csms.example.com/ocpp CP001 --port 8443
Without TLS, for example Home Assistant on its default port 9000 without SSL. These two commands are equivalent:
test-ocpp ws://homeassistant.local:9000 CP001
test-ocpp wss://homeassistant.local:9000 CP001 --no-tls
Server that requires a trailing slash. This connects to wss://csms.example.com/ocpp/CP001/:
test-ocpp wss://csms.example.com/ocpp CP001 --trailing-slash
OCPP 2.0.1:
test-ocpp wss://csms.example.com/ocpp CP001 --ocpp 2.0.1
Basic auth with a username and no password. This sends station-a: (an empty password):
test-ocpp wss://csms.example.com/ocpp CP001 --username station-a
Basic auth (security profile 2). The username defaults to the charge point ID:
test-ocpp wss://csms.example.com/ocpp CP001 --password secret
test-ocpp wss://csms.example.com/ocpp CP001 --username station-a --password secret
Client certificate (security profile 3), with a private CA:
test-ocpp wss://csms.example.com/ocpp CP001 \
--cert client.pem --key client.key --ca ca.pem
Server with a self-signed certificate. Pass the certificate with --ca to trust it, or use --insecure to skip verification:
test-ocpp wss://localhost:9000 CP001 --ca server.pem
test-ocpp wss://localhost:9000 CP001 --insecure
Custom vendor/model and a longer timeout:
test-ocpp wss://csms.example.com/ocpp CP001 \
--vendor Acme --model FastCharger --timeout 30
Use in a shell script or CI check:
if test-ocpp wss://csms.example.com/ocpp CP001 --password secret > /dev/null; then
echo "CSMS reachable"
fi
Example output
Connecting to wss://localhost:9443/CP001 (subprotocol ocpp1.6)
Connected. Negotiated subprotocol: ocpp1.6
TLS: TLSv1.3 TLS_AES_256_GCM_SHA384
--> [2, "0efb16e6-...", "BootNotification", {"chargePointVendor": "TestVendor", "chargePointModel": "TestModel"}]
<-- [3, "0efb16e6-...", {"status": "Accepted", "currentTime": "2026-10-12T00:00:00Z", "interval": 300}]
BootNotification status: Accepted
--> [2, "033cea3a-...", "Heartbeat", {}]
<-- [3, "033cea3a-...", {"currentTime": "2026-10-12T00:00:00Z"}]
Heartbeat server time: 2026-10-12T00:00:00Z
SUCCESS
Troubleshooting
| Output | Likely cause |
|---|---|
The 'websockets' package ... is not installed |
Running ./test-ocpp from a checkout without .venv. Follow From a source checkout |
server rejected handshake with HTTP 401 |
Wrong or missing credentials (--username / --password) |
server rejected handshake with HTTP 404 |
Wrong URL path or unknown charge point ID |
TLS error: ... CERTIFICATE_VERIFY_FAILED |
Server certificate isn't trusted. Pass --ca, or use --insecure for testing only |
WARNING: server did not accept the requested subprotocol |
Server doesn't support the chosen --ocpp version |
Connect call failed ... [Errno 111] |
Nothing is listening on that host and port. Check the port |
ValueError: Port out of range / URL must look like ws[s]://... |
Malformed URL. Use wss://host[:port][/path] or ws://host[:port][/path] |
server closed the connection (code 1000 ...) right after BootNotification |
The server accepted the connection but rejected the charge point. Usually the charge point ID isn't registered, authentication is missing, the OCPP version is wrong, or the server needs --trailing-slash. With Home Assistant, accept the charger first (see Home Assistant OCPP). Check the server logs |
ConnectionResetError or TLS error: ... WRONG_VERSION_NUMBER with wss:// |
The server may not use TLS on that port. Try ws:// or --no-tls |
TimeoutError |
Server unreachable, a firewall is blocking the connection, or no response within --timeout |
BootNotification failed: ... |
Server returned a CALLERROR, for example for an invalid payload |
If the server sends its own requests during the test, test-ocpp replies with a NotImplemented CALLERROR and keeps waiting for its own responses.
Python API
The same check is available from Python, for example in your own test suite:
import asyncio
from test_ocpp import check_connection
result = asyncio.run(check_connection(
"wss://csms.example.com/ocpp", "CP001",
ocpp="2.0.1", password="secret", timeout=10,
))
print(result.subprotocol, result.tls_version, result.boot_notification["status"])
check_connection takes the same options as the command line, as keyword arguments (port, tls, trailing_slash, username, password, cert, key, ca, insecure, vendor, model, timeout). It returns a ConnectionResult with url, subprotocol, tls_version, tls_cipher, boot_notification and heartbeat. Pass log=print to see the messages as the CLI prints them.
On failure it raises instead of returning: websockets.exceptions.InvalidStatus (HTTP error during the handshake), websockets.exceptions.ConnectionClosed, ssl.SSLError, OSError, asyncio.TimeoutError, test_ocpp.CallError (the server answered with a CALLERROR) or ValueError (malformed URL).
Home Assistant OCPP
With the Home Assistant OCPP integration, the first connection from a new charge point ID is expected to fail with server closed the connection (code 1000, no reason given). Home Assistant starts a discovery flow for the unknown charger and then closes the connection.
- In Home Assistant, open Settings → Devices & services and add the discovered OCPP charger.
- Wait for the integration to reload, then run
test-ocppagain with the same charge point ID.
Home Assistant uses the last path segment of the URL as the charge point ID and ignores slashes, so --trailing-slash makes no difference.
License
MIT. See LICENSE.
Metadata
Release files for test-ocpp 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| test_ocpp-1.0.0.tar.gz | 10.1 kB | With provenance | Details for test_ocpp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| test_ocpp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for test_ocpp-1.0.0-py3-none-any.whl |
Total release size: 21.2 kB
Release files / test_ocpp-1.0.0.tar.gz
| Download URL | test_ocpp-1.0.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0239f31422354e636a2748ac2a5e4e91ee1294dd20c8a4130563a43a1c197f4f
|
|
BLAKE2b-256 checksum How to use checksums |
430f9a657b5f0b78c84d3fe84a36ccba551a7bedb4d37d4eabf2acfe62ed5403
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / test_ocpp-1.0.0-py3-none-any.whl
| Download URL | test_ocpp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bfb36ab608108718b5984d4667626f0210bca50eace59e15b994713ddfcb2cd
|
|
BLAKE2b-256 checksum How to use checksums |
0c9ef2d9acf547aa62827b88e519f271af155388b4236d30de189b63b6565ca5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for test-ocpp 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for test_ocpp-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.