WebSocket River
The WebSocket River provides connectivity between a Predix Edge-enabled device and the Predix Time Series service in the cloud.
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
{
"name": "sensor_tag_1234",
"datapoints": [
[
1435854353541,
4
],
[
1435854356541,
2
]
],
"attributes": {
"asset_id": "UA231231",
"site_id": "LOC12"
}
}
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
- 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
Type | Contains | Size | Range |
---|---|---|---|
int | Signed integer | 32 bits | -2147483648 to 2147483647 |
long | Signed integer | 64 bits | -9223372036854775808 to 9223372036854775807 |
float | IEEE 754 floating point | 32 bits | ±1.4E-45 to ±3.4028235E+38 |
double | IEEE 754 floating point | 64 bits | ±4.9E-324 to ±1.7976931348623157E+308 |
True
is converted to 1
and False
is converted to 0
.Dependencies
- 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)"