FME Transformers: 2024.1
FME Transformers: 2024.1
WebSocketConnector
Connects to a WebSocket server to send or receive messages.
Typical Uses
- Receive messages from WebSocket Servers
- Send messages to WebSocket Servers
- Connect to FME Flow WebSocket Servers
How does it work?
The first input feature will cause the WebSocketConnector to initialize a connection to the specified WebSocket Server URL.
A ping message is sent to the server every 60 seconds to maintain the connection.
When Request > Action is Send, the specified Data to Transmit value will be sent to the WebSocket server for every input feature, including the first feature that initiated the connection.
When Request > Action is Receive, a feature will be produced each time a message is received, with the contents of the message in the _output attribute. Each incoming feature will cause the WebSocketConnector to initialize a connection to the specified WebSocket server. The transformer will block while it waits to receive WebSocket messages until the remote host closes the connection.
When Receive Mode is Batch, each input feature will only block until the specified number of messages is received. If set to Stream, the transformer will continue running until the host closes the connection.
Configuration
Input Ports
Input
This transformer accepts any feature.
Output Ports
Output
The output of this transformer will vary depending on the action performed.
- For the Receive action, received messages will be saved to the _output attribute value and output on a new feature
- A Send action will save the value of the sent message to an attribute
Initiator
The incoming feature is output through this port.
<Rejected>
Features that cause the operation to fail are output through this port. An fme_rejection_code attribute describing the category of the error will be added, along with a more descriptive fme_rejection_message attribute which contains more specific details as to the reason for the failure.
Note If a feature comes in to the WebSocketConnector already having a value for fme_rejection_code, this value will be removed.
Rejected Feature Handling: can be set to either terminate the translation or continue running when it encounters a rejected feature. This setting is available both as a default FME option and as a workspace parameter.
Parameters
Connection
WebSocket Server URL |
Specify the URL of the remote WebSocket server. The default value is ws://localhost:8080. To initiate a secure connection to a WebSocket server using TLS, specify wss://<hostname>:<port> . |
Verify Certificates |
Yes or No (default Yes). If Yes, the WebSocketConnector verifies the certificate (or chain of certificates) of the WebSocket server before establishing a connection. |
Connection Preamble |
(Optional) Provide a value to be transmitted to the WebSocket server after establishing a connection and before transmitting or receiving any specified data. To connect to the FME Flow WebSocket server, use the following preamble: { To specify this preamble, click the ellipsis (...) to open the Connection Preamble dialog. Under FME Flow WebSocket Preambles, select the Open Public Stream template. Then, specify a ws_stream_ids value. ws_stream_ids identifies one or more message streams in order for the WebSocket server to associate them with the correct requesting application. |
Request
Action |
Select the operation to perform. Choices are:
|
Message Encoding |
Select the encoding of the message. System Default (fme-system) is the default. When Action is Send, the Data to Transmit parameter is handled as an fme-system encoded string and transmitted as a utf-8 encoded string. If an encoding other than fme-system or utf-8 is selected, the value is encoded and sent as bytes. When Action is Receive, messages are received as bytes. The value of this parameter is used to decode the message to a string. If fme-binary is selected as an encoding for this parameter, the message will not be decoded and will remain intact as received. |
The remaining parameters available depend on the value of the Request > Action parameter. Parameters for each Action are detailed below.
Parameters - Receive Action
Receive Options
Mode |
Two message receiving options are available:
|
Maximum Batch Size |
When Mode is Batch, specify the number of messages to receive before closing the connection. |
Message Timeout (seconds) |
(Optional) Specify a duration in seconds after which the connection will close if no messages are received from the server. The default is empty - no timeout. Note that ping/pong frames sent from the server are not considered for the purpose of this timeout. |
Parameters - Send Action
Send Messages Options
Data to Transmit |
Specify the data to transmit to the WebSocket server. This may be a text value, an attribute value, or the result of an expression. The value of this parameter will be treated as an fme-system encoded string. To send a message to the FME Flow WebSocket server, use this template: { To specify this template, click the ellipsis (...) to open the Data to Transmit dialog. Under FME Flow WebSocket Messages, select the Send Message template. Then, specify a ws_msg value. |
Output Attributes
The following attributes can be selected for inclusion on the output features. Each output feature represents a message that was either sent or received.
_output |
The message sent or received, depending on the Action parameter:
|
_timestamp |
The time the message was created in unix time. |
Editing Transformer Parameters
Transformer parameters can be set by directly entering values, using expressions, or referencing other elements in the workspace such as attribute values or user parameters. Various editors and context menus are available to assist. To see what is available, click beside the applicable parameter.
How to Set Parameter Values
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
Content Types
These functions manipulate and format strings. | |
Special Characters |
A set of control characters is available in the Text Editor. |
Math functions are available in both editors. | |
Date/Time Functions | Date and time functions are available in the Text Editor. |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Creating and Modifying User Parameters | Create your own editable parameters. |
Dialog Options - Tables
Table Tools
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
For more information, see Transformer Parameter Menu Options.
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | |
Aliases | |
History |
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for all results about the WebSocketConnector on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver, Open Government Licence - British Columbia, and/or Open Government Licence – Canada.