WebSocket River

The WebSocket River provides connectivity between a Predix Edge-enabled device and the Predix Time Series service in the cloud.

The following figure illustrates the use case between the WebSocket River and the Predix Time Series service.
Figure 1. WebSocket River Use Case

WebSocket River to Time Series Service Data Transfer

The WebSocket River establishes a connection when you first attempt a data transfer and keeps that channel open for as long as possible. Each data transfer verifies that the WebSocket connection is open. If the connection has been closed, the service opens a new connection. The send operation is thread-safe, as only one active WebSocket connection exists at any given time.

Requests from the WebSocket Client to the WebSocket Server are asynchronous. To make sure that all requests are received by the Predix Time Series service, which acts as the WebSocket Server in this case, a management thread keeps a schedule of timeouts for all requests.

Data Format

The Time Series service requires data to be structured in a specific format as shown in c_Pushing_TimeSeries_Data.html#concept_0449dd2d-724f-4fd1-b49c-038886b155a5. To accommodate the Time Series format requirements, note the following Time Series format shown in the following example:
 
{
        "name": "sensor_tag_1234",
        "datapoints": [
            [
                1435854353541,
                4
            ],
            [
                1435854356541,
                2
            ]
        ],
        "attributes": {
            "asset_id": "UA231231",
            "site_id": "LOC12"
        }
}
 
WebSocket River's send() method accepts data in this format or in the format of a serialized PDataValue object. A sample for serializing a PDataValue object to the required format is shown below:

 
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write('[');
out.write(pDataValue.toBytes());
out.write(']');
 
WebSocketRiverRequest request = new WebSocketRiverRequest();
request.setData(pDataInputStream);
transferId = wsRiverSend.send(request);
 

If you are using WebSocket River with Spillway and the provided Machine Adapters (such as OPC-UA, Modbus, or HealthMonitor), this conversion will happen automatically. You do not need to perform any transformation in this case.

Limitations

Be aware of the following limitations when using the WebSocket River:
  • The WebSocket River is designed to be used with the Predix Time Series service, so you can send data to the Predix Time Series service only.
    Note: To send data to a WebSocket endpoint other than the Time Series service, you can use the WebSocket Client Service to enable your application to establish a WebSocket connection with a WebSocket server. See WebSocket Client Service.
  • You can pass data to the WebSocket River only in the format specified in the Data Format section.
  • The order in which requests are acknowledged is not guaranteed because communication is asynchronous.

Supported Numeric Data Types

TypeContainsSizeRange
intSigned integer32 bits-2147483648 to 2147483647
longSigned integer64 bits-9223372036854775808 to 9223372036854775807
floatIEEE 754 floating point32 bits±1.4E-45 to ±3.4028235E+38
doubleIEEE 754 floating point64 bits ±4.9E-324 to ±1.7976931348623157E+308
Note: Boolean values are converted to numeric data types. Boolean value of True is converted to 1 and False is converted to 0.

Dependencies

Maven dependencies and an OSGi import package are required to consume the service:
  • The following Maven dependency is required in the pom.xml file:
    
    <dependency>
        <groupId>com.ge.dspmicro</groupId>
        <artifactId>websocketriver-send</artifactId>
        <version>{version number}</version>
    </dependency>
    
  • The following OSGi import is required to consume the bundle:
    Import-Package: com.ge.dspmicro.websocketriver.send.api;version="[1.0,2)"