Description:

Sends messages to a WebSocket remote endpoint using a WebSocket session that is established by either ListenWebSocket or ConnectWebSocket.

Tags:

WebSocket, publish, send

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the Expression Language Guide.

Name Default Value Allowable Values Description
WebSocket Session Id ${websocket.session.id} A NiFi Expression to retrieve the session id. If not specified, a message will be sent to all connected WebSocket peers for the WebSocket controller service endpoint. Supports Expression Language: true
WebSocket ControllerService Id ${websocket.controller.service.id} A NiFi Expression to retrieve the id of a WebSocket ControllerService. Supports Expression Language: true
WebSocket Endpoint Id ${websocket.endpoint.id} A NiFi Expression to retrieve the endpoint id of a WebSocket ControllerService. Supports Expression Language: true
WebSocket Message Type TEXT The type of message content: TEXT or BINARY Supports Expression Language: true

Relationships:

Name Description
failure FlowFiles that failed to send to the destination are transferred to this relationship.
success FlowFiles that are sent successfully to the destination are transferred to this relationship.

Reads Attributes:
None specified.

Writes Attributes:

Name Description
websocket.controller.service.id WebSocket Controller Service id.
websocket.session.id Established WebSocket session id.
websocket.endpoint.id WebSocket endpoint id.
websocket.message.type TEXT or BINARY.
websocket.local.address WebSocket server address.
websocket.remote.address WebSocket client address.
websocket.failure.detail Detail of the failure.

State management:

This component does not store state.

Restricted:

This component is not restricted.

How to configure?

Step 1: Drag and drop the PutWebSocket processor to canvas.

Step 2: Double click the processor to configure. The configuration dialog will be opened as follows:

properties

Step 3: Check the usage of each property and update those values.

Properties and usage

All the following properties supports expression language.

WebSocket Session Id: Used to specify the session id of the WebSocket service.

WebSocket ControllerService Id: Used to specify the id of the WebSocket controller service.

WebSocket Endpoint Id: Used to specify the endpoint id of a WebSocket controller service.

WebSocket Message Type: Used to specify the type of the message to be send.

  • Text
  • Binary

For example, if you want to send messages to WebSocket client which has client-demo as endpoint id, configure the processor as follows:

properties