Skip to content

WebSocket Device Service

The WebSocket Device Service provides an easy way for third-party applications to push data into Edge Xpert via the WebSocket protocol. The current implementation is intended for one-way communication into Edge Xpert via asynchronous readings.

Breaking Change in Edge Xpert v2.2.1

The selfSigned field has changed to skipCertVerify in ws ProtocolProperty

Key Features

The WebSocket Device Service supports the following key features:

  • Support for both ws and wss schemes
  • Connection to multiple WebSocket endpoints
  • Retries after lost connection
  • Data parsing from incoming payloads
  • One-way communication, pushing data to Edge Xpert
  • Asynchronous readings

Connection Retry

The WebSocket Device Service will attempt to reconnect whenever a connection error is detected unless the endpoint explicitly sends the WebSocket Normal Closure Message.

By default, the device service will make ten reconnection attempts every five seconds. You can override the default time period by adding an environment variable, DRIVER_RETRYPERIOD, to your local docker-compose.yml file:

device-websocket:
...
  environment:
    <<: *common-variables
    SERVICE_HOST: device-websocket
    DRIVER_RETRYPERIOD: 10s

With the example above, WebSocket Device Service will attempt to reconnect to the remote endpoint ten times every ten seconds.

Supported Data Types

The WebSocket Device Service supports the following data types:

  • Bool
  • String
  • Uint8, Uint16, Uint32, Uint64
  • Int8, Int16, Int32, Int64
  • Float32, Float64

WebSocket Device Profile

In the WebSocket Device Service, each device resource represents a field in the JSON payload and a mandatory attribute named jsonPath must be specified. A device command represents a single Event aggregating one or more device resource(s) and will be pushed to Core Data.

Note

The WebSocket Device Service assumes each received data payload is in JSON format.

Using the WebSocket Device Service

An example of setting up and using Edge Xpert WebSocket Device Service can be found at WebSocket Example.