WebSockets Connector Reference | MuleSoft Documentation
# WebSockets Connector Reference
Support Version: Select
WebSockets Connector Version 1.0
Anypoint Connector for WebSockets (WebSockets Connector) provides communication through the WebSockets protocol, allowing external systems to open connections to the server (inbound sockets) or to establish connections to external systems (outbound socket). In both cases, full duplex traffic is supported.
Release Notes: WebSockets Connector Release Notes
## Configurations
### Default Configuration
Configure the name and connection types for the default configuration.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The name for this configuration. Connectors reference the configuration with this name.  
Connection | The connection types to provide to this configuration.  
The identifier of this element used to reference it in other components  
#### Connection Types
##### Connection
Configure the server, client, and reconnection parameters for the connection.
###### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Server Settings |  WebSocket Server Settings  
Client Settings |  WebSocket Client Settings  
Reconnection |  | When the application is deployed, a connectivity test is performed on all connectors. If set to `true`, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.  
## Operations
Anypoint Connector for WebSockets (WebSockets Connector) supports the following operations:
  *   * Bulk Close Sockets
  *   * Open Outbound Socket


### Associated Sources
  * On New Inbound Message
  * On New Inbound Connection
  * On Socket Closed
  * On New Outbound Message


## Broadcast
`<websocket:broadcast>`
Sends the content to all active WebSockets that match the path, socketType, and groups criteria. In the case of the path, the configured base path is not considered, as you can target both inbound and outbound sockets.
The message is sent to all the matching sockets, even though it’s possible that delivery to some of them fail. The operation returns a list of `BroadcastFailure` that contains details of each failure. If none fail, an empty list is returned.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
The content to send | #[payload]  
The path of the sockets to match  
Socket Type |  Enumeration, one of:
  * INBOUND
  * OUTBOUND

| The type of sockets to match  
Array of String | Matches sockets that belong to any of these groups  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Target Variable | The name of a variable to store the operation’s output  
Target Value | An expression to evaluate against the operation’s output and store the expression outcome in the target variable | #[payload]  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Array of Broadcast Failure  
---  
### For Configurations
  * Default Configuration


### Throws
  * WEBSOCKET:CONNECTIVITY
  * WEBSOCKET:RETRY_EXHAUSTED


## Bulk Close Sockets
`<websocket:bulk-close-sockets>`
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Socket Type |  Enumeration, one of:
  * INBOUND
  * OUTBOUND

  
Array of String  
Close Code |  Enumeration, one of:
  * NORMAL_CLOSURE
  * ENDPOINT_GOING_DOWN
  * PROTOCOL_ERROR
  * INVALID_DATA
  * MESSAGE_TOO_LARGE

| NORMAL_CLOSURE  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### For Configurations
  * Default Configuration


### Throws
  * WEBSOCKET:CONNECTIVITY
  * WEBSOCKET:RETRY_EXHAUSTED


## Close Socket
`<websocket:close-socket>`
This operation closes the socket.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Socket Id | The ID of the socket to close  
Close Code |  Enumeration, one of:
  * NORMAL_CLOSURE
  * ENDPOINT_GOING_DOWN
  * PROTOCOL_ERROR
  * INVALID_DATA
  * MESSAGE_TOO_LARGE

| The close code | NORMAL_CLOSURE  
The closing reason phrase  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### For Configurations
  * Default Configuration


### Throws
  * WEBSOCKET:CONNECTIVITY
  * WEBSOCKET:NO_SUCH_SOCKET
  * WEBSOCKET:RETRY_EXHAUSTED


## Open Outbound Socket
`<websocket:open-outbound-socket>`
This operation opens a new outbound socket.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Default Groups |  Array of String | The groups to which the socket should initially subscribe  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Path where the request is sent  
URL where to send the request  
HTTP headers the message should include  
URI Parameters | URI parameters to use to create the request  
Query Parameters | Query parameters the request should include  
Target Variable | The name of a variable to store the operation’s output  
Target Value | An expression to evaluate against the operation’s output and store the expression outcome in the target variable | #[payload]  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Attributes Type |  WebSocket Attributes  
---|---  
### For Configurations
  * Default Configuration


### Throws
  * WEBSOCKET:BASIC_AUTHENTICATION
  * WEBSOCKET:CONNECTIVITY
  * WEBSOCKET:FORBIDDEN
  * WEBSOCKET:INTERNAL_SERVER_ERROR
  * WEBSOCKET:INVALID_SOCKET_ID
  * WEBSOCKET:NO_SUCH_SOCKET
  * WEBSOCKET:NON_UNIQUE_SOCKET_ID
  * WEBSOCKET:NOT_FOUND
  * WEBSOCKET:REMOTELY_CLOSED
  * WEBSOCKET:RETRY_EXHAUSTED
  * WEBSOCKET:SERVICE_UNAVAILABLE
  * WEBSOCKET:UNAUTHORIZED


## Send
`<websocket:send>`
Sends the content through a specified socket.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Socket Id | The ID of the socket through which to send data  
The content to send | #[payload]  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### For Configurations
  * Default Configuration


### Throws
  * WEBSOCKET:CONNECTIVITY
  * WEBSOCKET:NO_SUCH_SOCKET
  * WEBSOCKET:RETRY_EXHAUSTED


## On New Inbound Message
`<websocket:inbound-listener>`
Exposes an endpoint through which external systems can connect through a WebSocket. This source triggers the owning flow each time one of those WebSockets sends information to this server. Additionally, any `websocket:on-inbound-connection` component with a matching path triggers when a socket connection is established.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Relative path from the path set in the configuration  
Default Groups |  Array of String | The groups to which newly created sockets should initially subscribe  
Output Mime Type | The MIME type of the payload that this operation outputs  
Output Encoding | The encoding of the payload that this operation outputs  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Primary Node Only | Whether this source should be executed only on the primary node when running in a cluster  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * non-repeatable-stream

| Configure to use repeatable streams  
Redelivery Policy |  Redelivery Policy | Defines a policy for processing the redelivery of the same message  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Attributes Type |  Inbound WebSocket Attributes  
---|---  
### For Configurations
  * Default Configuration
| Configure to use repeatable streams  
Redelivery Policy |  Redelivery Policy | Defines a policy for processing the redelivery of the same message  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Attributes Type |  Inbound WebSocket Attributes  
---|---  
### For Configurations
  * Default Configuration


## On New Inbound Connection
`<websocket:on-inbound-connection>`
Triggers when an inbound WebSocket connection is established.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Relative path from the path set in the configuration  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Primary Node Only | Whether this source should be executed only on the primary node when running in a cluster  
Redelivery Policy |  Redelivery Policy | Defines a policy for processing the redelivery of the same message  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Attributes Type |  WebSocket Attributes  
---|---  
### For Configurations
  * Default Configuration


## On Socket Closed
`<websocket:on-socket-closed>`
Triggers when a WebSocket is closed.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Relative path from the path set in the configuration  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Primary Node Only | Whether this source should be executed only on the primary node when running in a cluster  
Redelivery Policy |  Redelivery Policy | Defines a policy for processing the redelivery of the same message  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Closed Connection Event  
---  
Attributes Type |  WebSocket Attributes  
### For Configurations
  * Default Configuration


## On New Outbound Message
`<websocket:outbound-listener>`
Triggers when an outbound socket receives a message.
### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Configuration | The name of the configuration to use  
Relative path from the path set in the configuration  
Output Mime Type | The MIME type of the payload that this operation outputs  
Output Encoding | The encoding of the payload that this operation outputs  
Config Ref |  ConfigurationProvider | The name of the configuration to use to execute this component  
Primary Node Only | Whether this source should be executed only on the primary node when running in a cluster  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * non-repeatable-stream

| Configure to use repeatable streams  
Redelivery Policy |  Redelivery Policy | Defines a policy for processing the redelivery of the same message  
Reconnection Strategy | 
  *   * Reconnect Forever

| A retry strategy in case of connectivity errors  
### Output
Attributes Type |  WebSocket Attributes  
---|---  
### For Configurations
  * Default Configuration


## Types
### WebSocket Server Settings
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Listener Base Path** |  Base path to use for all resources served through this config.  
**Listener Config** |  Reference to the `http:listener-config` used to expose the inbound endpoint  
**Idle Socket Timeout** |  Timeout for automatically closing idle WebSockets  
**Idle Socket Timeout Unit** |  Enumeration, one of:
  * NANOSECONDS
  * MICROSECONDS
  * MILLISECONDS
  * SECONDS
  * MINUTES
  * HOURS

|  Time unit that qualifies the #idleSocketTimeout  
### WebSocket Client Settings
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Host where the requests is sent  
Port where the requests is sent. If the protocol attribute is WS (default), then the default value is `80`. If the protocol attribute is WSS, then the default value is `443`.  
Base path to use for all outbound sockets that reference this config  
Enumeration, one of: |  Protocol to use for outbound communication. Valid values are `WS` and `WSS`. Default value is `WS`. When using WSS, the HTTP communication is secured using TLS/SSL. If WSS is configured as the protocol, then the user can customize the TLS/SSL configuration by defining the `tls:context` parameter. If `tls:context` is not defined, then the default JVM certificates are used to establish communication.  
**Tls Context** |  Reference to a TLS config element that enables WSS for outbound sockets  
**Default Headers** |  Array of Header |  Default HTTP headers the message should include  
**Default Query Params** |  Array of Query Param |  Default query parameters the request should include  
**Connection Idle Timeout** |  A timeout for idle connections to be closed. If not specified, there is no timeout.  
**Connection Idle Timeout Unit** |  Enumeration, one of:
  * NANOSECONDS
  * MICROSECONDS
  * MILLISECONDS
  * SECONDS
  * MINUTES
  * HOURS

|  Timeout unit that qualifies the #connectionIdleTimeout  
**Follow Redirects** |  Specifies whether or not to follow redirects.  
**Preserve Headers Case** |  By default, header keys are stored internally in lower-case. This is to improve performance of headers handling and is functionally correct as specified in the RFC. ```
If a server expects headers in a specific case, set this flag to `true` to preserve the case of the header keys.
```
  
**Max Connections** |  The maximum number of outbound connections that will be kept open at the same time. By default the number of connections is unlimited.  
**Proxy Config** |  One of:
  * 
|  Reusable configuration element for outbound connections through a proxy. A proxy element must define host name and port attributes, and, optionally, can define a username and a password.  
**Authentication** |  HttpRequestAuthentication |  Authentication method to use for the HTTP request  
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Enabled Protocols** |  A comma-separated list of protocols enabled for this context  
**Enabled Cipher Suites** |  A comma-separated list of cipher suites enabled for this context  
**Trust Store**  
**Revocation Check** | 
  * Standard Revocation Check
  * Custom Ocsp Responder

  
### Trust Store
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
The location (which will be resolved relative to the current classpath and file system, if possible) of the trust store  
The password used to protect the trust store  
The type of store used  
The algorithm used by the trust store  
If set to `true`, no certificate validations are performed, which renders connections vulnerable to attacks. Use at your own risk.  
### Key Store
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
The location (which will be resolved relative to the current classpath and file system, if possible) of the key store  
The type of store used  
When the key store contains many private keys, this attribute indicates the alias of the key to use. If not defined, the first key in the file is used by default.  
**Key Password** |  The password used to protect the private key  
The password used to protect the key store  
The algorithm used by the key store  
### Standard Revocation Check
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Only End Entities** |  Verify only the last element of the certificate chain  
**Prefer Crls** |  Try CRL (instead of OCSP) first  
**No Fallback** |  Do not use the secondary checking method (the one not selected before)  
Avoid verification failure when the revocation server can not be reached or is busy  
### Custom Ocsp Responder
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
The URL of the OCSP responder  
**Cert Alias** |  Alias of the signing certificate for the OCSP response (must be in the trust store), if present  
### CRL File
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
The path to the CRL file.  
### Header
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
### Query Param
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
### Reconnection
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Fails Deployment** |  When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.  
**Reconnection Strategy** | 
  *   * Reconnect Forever
|  The reconnection strategy to use.  
### Reconnect
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
How often in milliseconds to reconnect  
If false, the reconnection strategy will run in a separate, non-blocking thread  
How many reconnection attempts to make.  
### Reconnect Forever
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
How often in milliseconds to reconnect  
If false, the reconnection strategy will run in a separate, non-blocking thread  
### Inbound WebSocket Attributes
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
HTTP version of the request  
**Local Address** |  Local host address from the server  
**Remote Address** |  Remote host address from the sender  
**Client Certificate** |  Client certificate (if two-way TLS is enabled)  
The socket ID  
**Socket Type** |  Enumeration, one of:
  * INBOUND
  * OUTBOUND

|  The socket type  
Array of String |  The groups on which this socket is subscribed  
Full path where the request was received  
**Request Uri** |  Full URI of the request  
Enumeration, one of: |  HTTP scheme of the request.  
**Query Params** |  Query parameters map built from the parsed string  
Headers map built from the parsed string  
**Uri Params** |  URI parameters extracted from the request path  
HTTP method of the request  
**Query String** |  Query string of the request  
### Repeatable In Memory Stream
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Initial Buffer Size** |  The amount of memory to allocate to consume the stream and provide random access to it. If the stream contains more data than can be fit into this buffer, then the buffer expands according to the bufferSizeIncrement attribute, with an upper limit of maxInMemorySize.  
**Buffer Size Increment** |  This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a `STREAM_MAXIMUM_SIZE_EXCEEDED` error is raised when the buffer gets full.  
**Max Buffer Size** |  The maximum amount of memory to use. If more than that is used then a `STREAM_MAXIMUM_SIZE_EXCEEDED` error is raised. A value lower than or equal to zero means no limit.  
**Buffer Unit** |  Enumeration, one of: |  The unit in which all these attributes are expressed  
### Repeatable File Store Stream
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**In Memory Size** |  Defines the maximum memory that the stream should use to keep data in memory. If more than that is consumed then it will start to buffer the content on disk.  
**Buffer Unit** |  Enumeration, one of: |  The unit in which maxInMemorySize is expressed  
### Redelivery Policy
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Max Redelivery Count** |  The maximum number of times a message can be redelivered and processed unsuccessfully before triggering a process-failed-message  
**Message Digest Algorithm** |  The secure hashing algorithm to use.  
**Message Identifier** |  Redelivery Policy Message Identifier |  Defines which strategy is used to identify the messages  
**Object Store** |  ObjectStore |  The object store where the redelivery counter for each message is stored  
### Redelivery Policy Message Identifier
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Use Secure Hash** |  Whether to use a secure hash algorithm to identify a redelivered message  
**Id Expression** |  Defines one or more expressions to use to determine when a message has been redelivered. This property can be set only if useSecureHash is false.  
### WebSocket Attributes
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
The socket ID  
**Socket Type** |  Enumeration, one of:
  * INBOUND
  * OUTBOUND

|  The socket type  
Array of String |  The groups to which this socket is subscribed  
Full path where the request was received  
**Request Uri** |  Full URI of the request  
Enumeration, one of: |  HTTP scheme of the request.  
**Query Params** |  Query parameters map built from the parsed string  
Headers map built from the parsed string  
**Uri Params** |  URI parameters extracted from the request path  
HTTP method of the request  
**Query String** |  Query string of the request  
### Closed Connection Event
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Enumeration, one of:
  * NORMAL_CLOSURE
  * ENDPOINT_GOING_DOWN
  * PROTOCOL_ERROR
  * INVALID_DATA
  * MESSAGE_TOO_LARGE

|  The close code  
The phrase with the reason the socket was closed  
### Broadcast Failure
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Error Message**  
Enumeration, one of:
  * INBOUND
  * OUTBOUND

  
### Proxy
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Host where the proxy requests is sent  
Port where the proxy requests is sent  
The username to authenticate against the proxy  
The password to authenticate against the proxy  
**Non Proxy Hosts** |  A list of comma-separated hosts against which the proxy should not be used  
### NTLM Proxy
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
**Ntlm Domain** |  The domain to authenticate against the proxy  
Host where the proxy requests is sent  
Port where the proxy requests is sent  
The username to authenticate against the proxy  
The password to authenticate against the proxy  
**Non Proxy Hosts** |  A list of comma-separated hosts against which the proxy should not be used  
## See Also
  * WebSocket Connector Overview
  * MuleSoft Help Center