Contact Us 1-800-596-4880

Sockets Connector Reference - Mule 4

Sockets Connector v1.1

Anypoint Connector for Sockets (Sockets Connector) provides a sockets listener, send capability, and send and receive functionality. Provides TCP and UDP requesters.

Configurations


Listener Config

Implementation of AbstractSocketConfig for listener sockets.

Parameters

Name Type Description Default Value Required

Name

String

The name of this configuration. With this name can be later referenced.

x 

Connection

The connection types that can be provided to this configuration.

x 

Default Encoding

String

Default encoding used for serializing String. This encoding is used in the SocketOperations#send(RequesterConnection, RequesterConfig, Object, String, String, Message) operation for serializing String types if no encoding parameter is specified. It is also used by the SocketWorker for encoding the replies send by the SocketListener source.

 

Connection Types

TCP Listener

A ConnectionProvider which provides instances of TcpListenerConnection to be used by SocketListener.

Parameters
Name Type Description Default Value Required

Protocol

TcpProtocol that knows how the data is going to be read and written. If not specified, the SafeProtocol will be used.

 

TLS Configuration

TLS

Its presence will imply the use of SSLServerSocket instead of plain TCP ServerSocket for accepting new SSL connections.

 

Port

Number

Connection's port number

x 

Host

String

Connection's host name

x 

Reconnection Strategy

A retry strategy in case of connectivity errors

 

Disable Validation

Boolean

Disables connection validation

 

Send Buffer Size

Number

The size of the buffer (in bytes) used when sending data, set on the socket itself.

 

Receive Buffer Size

Number

The size of the buffer (in bytes) used when receiving data, set on the socket itself.

 

Client Timeout

Number

This sets the SO_TIMEOUT value on sockets. Indicates the amount of time (in milliseconds) that the socket will wait in a blocking operation before failing. A value of 0 (the default) means waiting indefinitely.

 

Reuse Address

Boolean

If set (the default), SO_REUSEADDRESS is set on the sockets before binding. This helps reduce "address already in use" errors when a socket is re-used.

true

 

Send TCP With No Delay

Boolean

If set, transmitted data is not collected together for greater efficiency but sent immediately. Defaults to true even though Socket default is false because optimizing to reduce amount of network traffic over latency is hardly ever a concern today.

true

 

Linger

Number

This sets the SO_LINGER value. This is related to how long (in milliseconds) the socket will take to close so that any remaining data is transmitted correctly.

 

Keep Alive

Boolean

Enables SO_KEEPALIVE behavior on open sockets. This automatically checks socket connections that are open but unused for long periods and closes them if the connection becomes unavailable. This is a property on the socket itself and is used by a server socket to control whether connections to the server are kept alive before they are recycled.

false

 

Fail On Unresolved Host

Boolean

Whether the socket should fail during its creation if the host set on the endpoint cannot be resolved. However, it can be set to false to allow unresolved hosts (useful when connecting through a proxy).

true

 

Server Timeout

Number

This sets the SO_TIMEOUT value when the socket is used as a server. This is the timeout that applies to the "accept" operation. A value of 0 (the ServerSocket default) causes the accept to wait indefinitely (if no connection arrives).

 

Receive Backlog

Number

The maximum queue length for incoming connections.

50

 

UDP Listener

A ConnectionProvider which provides instances of UdpListenerConnection to be used by SocketListener.

Parameters
Name Type Description Default Value Required

Port

Number

Connection's port number

x 

Host

String

Connection's host name

x 

Reconnection Strategy

A retry strategy in case of connectivity errors

 

Disable Validation

Boolean

Disables connection validation

 

Send Buffer Size

Number

The size of the buffer (in bytes) used when sending data, set on the socket itself.

 

Receive Buffer Size

Number

The size of the buffer (in bytes) used when receiving data, set on the socket itself.

 

Client Timeout

Number

This sets the SO_TIMEOUT value on sockets. Indicates the amount of time (in milliseconds) that the socket will wait in a blocking operation before failing. A value of 0 (the default) means waiting indefinitely.

 

Reuse Address

Boolean

If set (the default), SO_REUSEADDRESS is set on the sockets before binding. This helps reduce "address already in use" errors when a socket is re-used.

true

 

Broadcast

Boolean

Enable/disable SO_BROADCAST into the DatagramSocket

false

 

Associated Sources


Request Config

Implementation of AbstractSocketConfig for requester sockets.

Parameters

Name Type Description Default Value Required

Name

String

The name of this configuration. With this name can be later referenced.

x 

Connection

The connection types that can be provided to this configuration.

x 

Default Encoding

String

Default encoding used for serializing String. This encoding is used in SocketOperations#send(RequesterConnection, RequesterConfig, Object, String, String, Message) operation for serializing String types if no encoding parameter is specified. It is also used by the SocketWorker for encoding the replies send by the SocketListener source.

 

Connection Types

TCP Requester

A ConnectionProvider which provides instances of TcpRequesterConnection to be used by the SocketOperations.

Parameters
Name Type Description Default Value Required

Local Address Settings

This configuration parameter refers to the address where the Socket should bind to.

 

Protocol

TcpProtocol that knows how the data is going to be read and written. If not specified, the SafeProtocol will be used.

 

TLS Configuration

TLS

Its presence will imply the use of SSLSocket instead of plain TCP Socket for establishing a connection over SSL.

 

Port

Number

Connection's port number

x 

Host

String

Connection's host name

x 

Reconnection Strategy

A retry strategy in case of connectivity errors

 

Disable Validation

Boolean

Disables connection validation

 

Pooling Profile

Characteristics of the connection pool

 

Send Buffer Size

Number

The size of the buffer (in bytes) used when sending data, set on the socket itself.

 

Receive Buffer Size

Number

The size of the buffer (in bytes) used when receiving data, set on the socket itself.

 

Client Timeout

Number

This sets the SO_TIMEOUT value on sockets. Indicates the amount of time (in milliseconds) that the socket will wait in a blocking operation before failing. A value of 0 (the default) means waiting indefinitely.

 

Reuse Address

Boolean

If set (the default), SO_REUSEADDRESS is set on the sockets before binding. This helps reduce "address already in use" errors when a socket is re-used.

true

 

Send TCP With No Delay

Boolean

If set, transmitted data is not collected together for greater efficiency but sent immediately. Defaults to true even though Socket default is false because optimizing to reduce amount of network traffic over latency is hardly ever a concern today.

true

 

Linger

Number

This sets the SO_LINGER value. This is related to how long (in milliseconds) the socket will take to close so that any remaining data is transmitted correctly.

 

Keep Alive

Boolean

Enables SO_KEEPALIVE behavior on open sockets. This automatically checks socket connections that are open but unused for long periods and closes them if the connection becomes unavailable. This is a property on the socket itself and is used by a server socket to control whether connections to the server are kept alive before they are recycled.

false

 

Fail On Unresolved Host

Boolean

Whether the socket should fail during its creation if the host set on the endpoint cannot be resolved. However, it can be set to false to allow unresolved hosts (useful when connecting through a proxy).

true

 

Connection Timeout

Number

Number of milliseconds to wait until an outbound connection to a remote server is successfully created. Defaults to 30 seconds.

30000

 

UDP Requester

A ConnectionProvider which provides instances of UdpRequesterConnection to be used by the SocketOperations.

Parameters
Name Type Description Default Value Required

Local Address Settings

This configuration parameter refers to the address where the DatagramSocket should bind to.

 

Port

Number

Connection's port number

x 

Host

String

Connection's host name

x 

Reconnection Strategy

A retry strategy in case of connectivity errors

 

Disable Validation

Boolean

Disables connection validation

 

Pooling Profile

Characteristics of the connection pool

 

Send Buffer Size

Number

The size of the buffer (in bytes) used when sending data, set on the socket itself.

 

Receive Buffer Size

Number

The size of the buffer (in bytes) used when receiving data, set on the socket itself.

 

Client Timeout

Number

This sets the SO_TIMEOUT value on sockets. Indicates the amount of time (in milliseconds) that the socket will wait in a blocking operation before failing. A value of 0 (the default) means waiting indefinitely.

 

Reuse Address

Boolean

If set (the default), SO_REUSEADDRESS is set on the sockets before binding. This helps reduce "address already in use" errors when a socket is re-used.

true

 

Broadcast

Boolean

Enable/disable SO_BROADCAST into the DatagramSocket

false

 

Associated Operations

Operations

Send

<http://www.mulesoft.org/schema/mule/sockets:send>

Sends the data using the client associated to the RequesterConnection.

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x 

Content

Any

Data that will be serialized and sent through the socket.

#[payload]

 

Output Encoding

String

Encoding that will be used to serialize the data if its type is String.

 

For Configurations

Throws

  • SOCKETS:RETRY_EXHAUSTED  

  • SOCKETS:CONNECTIVITY  

Send And Receive

<http://www.mulesoft.org/schema/mule/sockets:send-and-receive>

Sends the data using the client associated to the RequesterConnection, and then blocks until a response is received or the timeout is met, in which case the operation will return a null payload.

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x 

Content

Any

data that will be serialized and sent through the socket.

#[payload]

 

Output Encoding

String

encoding that will be used to serialize the data if its type is String.

 

Streaming Strategy

Configure if repeatable streams should be used and their behavior.

 

Target Variable

String

The name of a variable on which the operation's output will be placed.

 

Output

Type

Binary

Attributes Type

SocketAttributes

For Configurations

Throws

  • SOCKETS:RETRY_EXHAUSTED  

  • SOCKETS:CONNECTIVITY  

Sources

Socket Listener

<http://www.mulesoft.org/schema/mule/sockets:socket-listener>

Parameters

Name Type Description Default Value Required

Configuration

String

The name of the configuration to use.

x 

Redelivery Policy

Defines a policy for processing the redelivery of the same message

 

Streaming Strategy

Configure if repeatable streams should be used and their behavior.

 

Reconnection Strategy

A retry strategy in case of connectivity errors

 

Response Value

Any

#[mel:payload]

 

Output

Type

Binary

Attributes Type

SocketAttributes

For Configurations

Throws

  • MULE:SOURCE_RESPONSE_SEND  

  • MULE:SOURCE_ERROR_RESPONSE_SEND  

  • MULE:SOURCE_ERROR_RESPONSE_GENERATE  

  • MULE:SOURCE_RESPONSE_GENERATE  

Types

TLS

Field Type Default Value

Enabled Protocols

String

Enabled Cipher Suites

String

Trust Store

Key Store

Trust Store

Field Type Default Value

Path

String

Password

String

Type

  • Enumeration, one of:

    • jks

    • jceks

    • pkcs12

  • String

Algorithm

String

Insecure

Boolean

Key Store

Field Type Default Value

Path

String

Type

  • Enumeration, one of:

    • jks

    • jceks

    • pkcs12

  • String

Alias

String

Key Password

String

Password

String

Algorithm

String

Reconnect

Field Type Description Default Value Required

Frequency

Number

How often in milliseconds to reconnect.

Count

Number

How many reconnection attempts to make.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread.

true

Reconnect Forever

Field Type Description Default Value Required

Frequency

Number

How often in milliseconds to reconnect.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread.

true

Redelivery Policy

Field Type Default Value

Max Redelivery Count

Number

Use Secure Hash

Boolean

Message Digest Algorithm

String

Id Expression

String

Object Store Ref

String

Repeatable In Memory Stream

Field Type Default Value

Initial Buffer Size

Number

Buffer Size Increment

Number

Max Buffer Size

Number

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Repeatable File Store Stream

Field Type Default Value

Max In Memory Size

Number

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Socket Connection Settings

Field Type Default Value

Port

Number

Host

String

Pooling Profile

Field Type Default Value

Max Active

Number

Max Idle

Number

Max Wait

Number

Min Eviction Millis

Number

Eviction Check Interval Millis

Number

Exhausted Action

Enumeration, one of:

  • WHEN_EXHAUSTED_GROW

  • WHEN_EXHAUSTED_WAIT

  • WHEN_EXHAUSTED_FAIL

Initialisation Policy

Enumeration, one of:

  • INITIALISE_NONE

  • INITIALISE_ONE

  • INITIALISE_ALL

Disabled

Boolean

Safe Protocol

Field Type Default Value

Max Message Length

Number

-1

Rethrow Exception On Read

Boolean

false

Direct Protocol

Field Type Default Value

Rethrow Exception On Read

Boolean

false

Length Protocol

Field Type Default Value

Max Message Length

Number

-1

Rethrow Exception On Read

Boolean

false

Streaming Protocol

Field Type Default Value

Rethrow Exception On Read

Boolean

false

XML Message Protocol

Field Type Default Value

Rethrow Exception On Read

Boolean

false

XML Message Eof Protocol

Field Type Default Value

Rethrow Exception On Read

Boolean

false

Custom Protocol

Field Type Default Value

Class

String

EOF Protocol

Field Type Default Value

Rethrow Exception On Read

Boolean

false

Custom Class Loading Length Protocol

Field Type Default Value

Class Loader

Any

Max Message Length

Number

-1

Rethrow Exception On Read

Boolean

false

View on GitHub