Skip to content

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 ​

ItemRequirement
WebSocket ServerAccessible by the camera, WebSocket service started
Address Formatws://<ServerIP>:<Port>
PortWebSocket service port (per server configuration)
JWT AuthenticationOptional: when enabled, camera must carry a valid token (expired/invalid tokens will be rejected)
Message FormatBare 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 ​

  1. Navigate to Result Integration → WebSocket;
  2. Turn on the WebSocket Integration switch;
  3. 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 add ws:// again.

  1. (Optional) Turn on the JWT Authentication switch and configure the token and validity period as required by the server;
  2. Click Save.

Basic Verification ​

Without JWT ​

  1. Start the WebSocket server and listen on a port;
  2. Configure the camera address as <ServerIP>:<Port> (without JWT), trigger AI inference / defect reporting;
  3. Observe on the server side: "Client connected" + complete JSON message received → Integration successful.

With JWT ​

  1. Generate a token per server convention (e.g., configure secret key / validity period);
  2. Start the server with JWT verification enabled:
    • Strict signature verification: start with the secret key;
    • Legality-only check: enable corresponding parameters per server documentation;
  3. Enter the token and validity period on the camera, trigger reporting;
  4. Server-side verification passes, connection established, JSON message received → Integration successful; invalid/expired tokens will be rejected.

Common Issues ​

SymptomTroubleshooting
Camera cannot connect to serverCheck if server is started and listening on the port; camera's server IP/port is correct; firewall allows traffic
Connected but no message receivedCamera has not triggered inference/reporting; or wrong send address filled in
Connection immediately disconnectedNormal behavior (fire-and-forget: disconnects after sending)
Connection rejected in JWT modeVerify that the token signing key is consistent, token is not expired, and the entered token is correct