WebSocket Integration
Function path: SVE navigation bar → Result Integration → WebSocket
Overview
The smart camera acts as a WebSocket client, establishing a long connection (full-duplex) with the server and sending AI inference results as bare JSON text frames in real-time to the server (disconnects after sending). JWT authentication can optionally be enabled; the server verifies the token during the handshake phase before establishing the connection.
Integration Requirements
| Item | Requirement |
|---|---|
| WebSocket Server | Accessible by the camera, WebSocket service started |
| Address Format | ws://<ServerIP>:<Port> |
| Port | WebSocket service port (per server configuration) |
| JWT Authentication | Optional: when enabled, camera must carry a valid token (expired/invalid tokens will be rejected) |
| Message Format | Bare JSON text frame (IntegrateResult: appId / cameraId / timestamp / originImg / maskImg / finalImg / additional) |
Camera-side Message Example
json
{
"appId": "app-id",
"appVersion": "1.0.0",
"cameraId": "1",
"timestamp": "20260910_101725794",
"originImg": "http://<CameraIP>:58200/files/temp/xxx.jpg",
"maskImg": "http://<CameraIP>:58200/files/temp/xxx.jpg",
"finalImg": "http://<CameraIP>:58200/files/temp/xxx.jpg",
"additional": { "svResult": "NG" }
}Basic Configuration on SVE
- Navigate to Result Integration → WebSocket;
- Turn on the WebSocket Integration switch;
- Fill in WebSocket Address:
<ServerIP>:<Port>;
Note: The "WebSocket Address" input field in the SVE interface already includes the
ws://prefix. You only need to enter the IP and port — no need to addws://again.
- (Optional) Turn on the JWT Authentication switch and configure the token and validity period as required by the server;
- Click Save.
Basic Verification
Without JWT
- Start the WebSocket server and listen on a port;
- Configure the camera address as
<ServerIP>:<Port>(without JWT), trigger AI inference / defect reporting; - Observe on the server side: "Client connected" + complete JSON message received → Integration successful.
With JWT
- Generate a token per server convention (e.g., configure secret key / validity period);
- Start the server with JWT verification enabled:
- Strict signature verification: start with the secret key;
- Legality-only check: enable corresponding parameters per server documentation;
- Enter the token and validity period on the camera, trigger reporting;
- Server-side verification passes, connection established, JSON message received → Integration successful; invalid/expired tokens will be rejected.
Common Issues
| Symptom | Troubleshooting |
|---|---|
| Camera cannot connect to server | Check if server is started and listening on the port; camera's server IP/port is correct; firewall allows traffic |
| Connected but no message received | Camera has not triggered inference/reporting; or wrong send address filled in |
| Connection immediately disconnected | Normal behavior (fire-and-forget: disconnects after sending) |
| Connection rejected in JWT mode | Verify that the token signing key is consistent, token is not expired, and the entered token is correct |