Operator WebSocketInject

IBMStreams streamsx.inetserver Toolkit > com.ibm.streamsx.inetserver 4.0.0 > com.ibm.streamsx.inet.wsserver > WebSocketInject

Operator recieves messages from WebSocket clients and generates a tuple which is sent to streams. Upon startup, this operator is registered to the common pe-wide jetty web server. Clients may connect to the websocket URL /output/0/wsinject. Each received message is output as tuple. The data received is dependent upon the input ports schema.

HTTPS Support and Sharing the Jetty Server

see also namespace:com.ibm.streamsx.inet

Summary

Ports
This operator has 0 input ports and 1 output port.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 13 parameters.

Optional: ackCount, certificateAlias, context, contextResourceBase, enableConnectionControlMessages, keyPassword, keyStore, keyStorePassword, messageAttributeName, port, senderIdAttributeName, trustStore, trustStorePassword

Metrics
This operator reports 4 metrics.

Properties

Implementation
Java

Output Ports

Assignments
Java operators do not support output assignments.
Ports (0)

This output port injects the received web socket messages into the Streams application. If the port has one attribute, this attribute is used for the web socket messages and must be of type rstring, ustring or blob. If the port has more than one attribute, the output mapping is determined with parameters messageAttributeName and senderIdAttributeName. Subsequent attribute(s) are allowed but will not be poplulated.

Properties

Parameters

This operator supports 13 parameters.

Optional: ackCount, certificateAlias, context, contextResourceBase, enableConnectionControlMessages, keyPassword, keyStore, keyStorePassword, messageAttributeName, port, senderIdAttributeName, trustStore, trustStorePassword

ackCount

The operator sends out an ack message to all currently connected clients. An ack message is sent when the (totaslNumberOfMessagesRecieved % ackCount) == 0, The ack message is a in JSON format { status:'COUNT', text:<totalNumberOfMessagesReceived>}. Default value is 0, no ack messages will be sent.

Properties
certificateAlias

Alias of the certificate to use in the key store. When this parameter is set all connections use HTTPS and parameters keyStore and keyPassword are required.

Properties
context

Define a URL context path that maps to the resources defined bycontextResourceBase. This allows a composite that invokes this operator in a toolkit to provide resources regardless of the value of the application's data directory. For example setting it to maps would result in the URL /maps/index.html mapping to the file index.html in the directory defined by contextResourceBase. Requires the parameter contextResourceBase to be set. If when the operator is initialized the context already exists then no action is taken. This allows multiple independent composites in the same toolkit to have common context and contextResourceBase settings, typically to point to a single set of HTML and Javascript resources for the toolkit.

If the operator provides URLs for its input or output ports then they are placed in the this context when this parameter is set. This then provides fixed locations for the URLs regardless of the depth of the operator invocation in the main composite.

Only a single context per invocation is supported.

Properties
contextResourceBase

Directory location of resources that will be available through the the URL context defined by the parameter context. Typically used to allow a toolkit to provide a set of resources in a fixed location. The set of resources is recommended to be stored in the application_dir/opt directory, which is automatically included in the bundle by default. Path of this directory can be absolute or relative, if relative path is specified then it is relative to the application directory. A set of default resources is included in the toolkit directory under ToolkitDir/opt/resources and will be loaded by the operator. This default resources can be viewed at http://hostname:8080/streamsx.inet.resources. A path within the application is obtained using the SPL function getThisToolkitDir(). Thus a composite in the file maps.spl in the namespace directory com.acme.streams.apps.map might have the following setting to map http://127.0.0.1:8080/maps to opt/resources/mapinfo in the application.

param
  context: “maps”
  contextResourceBase: getThisToolkitDir() + “/opt/resources/mapinfo”
Properties
enableConnectionControlMessages

If this parameteter is true, the operator sends out a connection control message to all connected websocket clients, when a client gets connected or disconnected. Default is true.

Properties
keyPassword

Password to the private key.

Properties
keyStore

URL to the key store containing the certificate. If a relative file path then it is taken as relative to the application directory.

Properties
keyStorePassword

Password to the key store.

Properties
messageAttributeName

Output port's attribute that the data received will be stored to. The type of this attribute must be rstring, ustring or blob. If the output port has more than one attribute this parameter is required.

Properties
port

Port number for the embedded Jetty HTTP server, default: "8080". If the port is set to 0, the jetty server uses a free tcp port, and the metric serverPort delivers the actual value.

Properties
senderIdAttributeName

Output port attribute that will we loaded with the message sender's identifier, this identifier is consistent during the lifetime of the sender's session. The type of this attribute must be rstring or ustring.

Properties
trustStore

URL to the trust store containing client certificates. If a relative file path then it is taken as relative to the application directory. When this parameter is set, client authentication is required.

Properties
trustStorePassword

Password to the trust store.

Properties

Metrics

https - Gauge

Jetty SSL/TLS status: 0=HTTP, 1=HTTPS.

nClientsConnected - Gauge

Number of clients currently connected to the operators WebSocket context.

nMessagesReceived - Counter

Number of messages received via WebSocket. (cumulative sum for all connected clients)

serverPort - Gauge

Jetty (HTTP/HTTPS) server port if the operator hosts the server, 0 otherwise

Libraries

Operator class library
Library Path: ../../impl/lib/com.ibm.streamsx.inetserver.jar