---
schema_version: "1"
id: 6bdb1dab699f74d19785ef4a8db6d6cd30e38df7306cb44c16f9c650baf95a69
title: Using Anypoint Studio to Configure Sockets Connector 1.2
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/sockets-connector/latest/sockets-connector-studio.md
canonical_url: https://docs.mulesoft.com/sockets-connector/latest/sockets-connector-studio
source_site: docs.mulesoft.com
content_type: documentation
content_hash: aaf5bf9a2647f11b047b9ab4209efda50a71a91d756dbbb7d804247ad8ac1f5e
description: MuleSoft Documentation Site
release: "1.2"
latest: true
---
---
product: Sockets Connector
version: 1.2
is-latest-version: true
---

# Using Anypoint Studio to Configure Sockets Connector 1.2

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and
configuration files.

To add and configure a connector in Studio:

1.  [Create a Mule project](#create-mule-project).

2.  [Add the connector to your Mule project](#add-connector-to-project).

3.  [Configure the Sockets Listener source for the connector’s flow](#configure-input-source).

4.  [Configure the Send and Receive operations in the flow](#add-connector-operation).

5.  [Configure supported TCP protocols](#configure-other-fields).

If you are new to configuring connectors in Studio, see
[Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio).
If, after reading this topic, you need additional information about the connector fields, see the
[Sockets Connector Reference](https://docs.mulesoft.com/sockets-connector/latest/sockets-documentation).

## Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

1.  In Studio, select **File > New > Mule Project**.

2.  Enter a name for your Mule project and click **Finish**.

## Add the Connector to Your Mule Project

Add Anypoint Connector for Sockets (Sockets Connector) to your Mule project to automatically
populate the XML code with the connector’s namespace and schema location and add the required
dependencies to the project’s `pom.xml` file:

1.  In the **Mule Palette** view, click **(X) Search in Exchange**.

2.  In the **Add Dependencies to Project** view, type `sockets` in the search field.

3.  Click **Sockets** in **Available modules**.

4.  Click **Add**.

5.  Click **Finish**.

Adding a connector to a Mule project in Studio does not make that connector available to other
projects in your Studio workspace.

## Configure the Sockets Listener Source

A source initiates a flow when a specified condition is met. The Sockets Listener source represents
a socket endpoint to which clients can connect. By browsing to this endpoint, external clients
establish a TCP or UDP socket connection and trigger the flow each time they send a message:

1.  In the **Mule Palette** view, select **Sockets** > **Listener**.

2.  Drag **Listener** to the Studio canvas.

3.  On the **Listener** configuration screen, optionally change the value of the **Display Name**
    field.

4.  Click the plus sign (+) next to the **Connector configuration** field to configure a global
    element that can be used by all instances of `sockets listener` in the app.

5.  On the **General** tab, for **Connection** select the `Tcp listener` or the `Udp listener`
    connections.

6.  Configure the specific tabs for the selected connection:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Tab Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>General</strong></p></td><td><p>Set the required <strong>Host</strong> and <strong>Port</strong> attributes and configure any other optional fields.</p></td></tr><tr><td><p><strong>Buffer Configuration</strong></p></td><td><p>Optionally specify send and receive buffer size information.</p></td></tr><tr><td><p><strong>TLS</strong></p></td><td><p>Optionally specify the TLS information.</p></td></tr><tr><td><p><strong>Timeout Configuration</strong></p></td><td><p>Optionally specify the client and server timeout information.</p></td></tr><tr><td><p><strong>Advanced</strong></p></td><td><p>Optionally specify the reconnection information, including a reconnection strategy.</p></td></tr></tbody></table>

7.  Click **Test Connection** to confirm that Mule can connect with the specific server.

8.  Click **OK**.

In Studio, the Sockets Listener source in the flow looks like this:

![Sockets Listener Source](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-listener-source.png)

Figure 1. Sockets Listener Source

In Studio, configuring the Sockets Listener source with a TCP connection to accept local incoming
connections on port `8082` looks like this:

![Sockets Listener Source Configuration](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-listener-configuration.png)

Figure 2. Sockets Listener Source Configuration

In the **Configuration XML** tab, the XML looks like this:

```xml
	<sockets:listener-config name="Sockets_Listener_config">
		<sockets:tcp-listener-connection host="localhost" port="8082" />
	</sockets:listener-config>

	<flow name="SocketsFlow" >
		<sockets:listene config-ref="Sockets_Listener_config"/>
	</flow>
```

## Configure the Send Operation and the Send and Receive Operation

When you add a connector operation to your flow, you immediately define a specific operation for
that connector to perform. Sockets Connector provides two basic operations:

- Send  
  Sends the data using the client associated to the RequesterConnection

- Send and receive  
  Sends the data using the associated client and then blocks until a response is received or the
  timeout is met, in which case the operation returns a null payload

To configure the Send operation or the Send and Receive operation:

1.  In the **Mule Palette** view, select either:

    - **Sockets** > **Send**

    - **Sockets** > **Send and receive**.

2.  Drag the **Send** or the **Send and receive** operation to the Studio canvas.

3.  On the operation configuration screen, optionally change the value of the **Display Name**
    field.

4.  Click the plus sign (+) next to the **Connector configuration** field to configure a global
    element that can be used by all instances of `Sockets Send` or `Sockets Send and receive` in the
    app.

5.  On the **General** tab, for **Connection** select the `Tcp requester` or the `Udp requester`
    connections.

6.  Configure the specific tabs for the selected connection:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Tab Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>General</strong></p></td><td><p>Set the required <strong>Host</strong> and <strong>Port</strong> attributes and configure optional fields as required.</p></td></tr><tr><td><p><strong>Buffer Configuration</strong></p></td><td><p>Optionally specify send and receive buffer size information.</p></td></tr><tr><td><p><strong>Connection</strong></p></td><td><p>Optionally select and configure one of the supported TCP protocols.</p></td></tr><tr><td><p><strong>Local Address Settings</strong></p></td><td><p>Optionally specify the local address.</p></td></tr><tr><td><p><strong>TLS</strong></p></td><td><p>Optionally specify the TLS information.</p></td></tr><tr><td><p><strong>Timeout Configuration</strong></p></td><td><p>Optionally specify the client and server timeout information.</p></td></tr><tr><td><p><strong>Advanced</strong></p></td><td><p>Optionally specify the reconnection information, including a reconnection strategy.</p></td></tr></tbody></table>

7.  Click **Test Connection** to confirm that Mule can connect with the specific server.

8.  Click **OK**.

Additionally, for the **Send and receive** operation, configure the MIME type as follows:

1.  Click the **Send and receive** operation from your flow.

2.  On the **MIME Type** tab, select a MIME type from field menu.

In Studio, the Sockets Send operation and Send and receive operation in the flow look like this:

![Sockets Send operation Send and Receive operation](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-send-operation.png)

Figure 3. Sockets Send operation Send and Receive operation

In Studio, configuring either the Send operation or the Send and receive operation with a TCP
connection to accept local incoming connections on port `8082` looks like this:

![Sockets Send operation or Send and Receive operation configuration](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-sendreceive-configuration.png)

Figure 4. Sockets Send operation or Send and Receive operation configuration

In the **Configuration XML** tab, the Send operation configuration XML looks like this:

```xml
<sockets:request-config name="Sockets_Send_config">
		<sockets:tcp-requester-connection host="localhost" port="8082" />
	</sockets:request-config>

	<flow name="SocketsFlow" >
		<sockets:send config-ref="Sockets_Send_config"/>
	</flow>
```

In Studio, configuring the MIME type as `application/json` for the Send and receive operation looks
like this:

![Sockets MIME type Configuration](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-mimetype-configuration.png)

Figure 5. Sockets MIME Type Configuration

In the **Configuration XML** tab, the Send and receive operation configuration XML looks like this:

```xml
<sockets:request-config name="Sockets_Send_config">
	<sockets:tcp-requester-connection host="localhost" port="8082" />
</sockets:request-config>

<flow name="SocketsFlow" >
	<sockets:send-and-receive config-ref="Sockets_Send_Receive_config" outputMimeType="application/json"/>
</flow>
```

## Configure the Supported TCP Protocols

Sockets Connector supports application-level protocols implemented on top of TCP. You must implement
these protocols in both client and server ends so they can work properly.  
By default, the Sockets Connector implements the Safe Protocol; however, you can configure a
different protocol for the connector operations both in Anypoint Studio and XML.

Supported TCP protocols include the following:

- Direct Protocol  
  The socket reads until no more bytes are immediately available. On slow networks, `EOFProtocol`
  and `LengthProtocol` might be more reliable.

- EOF Protocol  
  Reading is terminated by the stream being closed by the client.

- Length Protocol  
  This protocol is defined by sending or reading an integer (the packet length) and then the data to
  transfer.

- Custom Class Loading Length Protocol  
  A length protocol that uses a specific class loader to load objects from streams.

- Safe Protocol  
  A test protocol that precedes every message with a cookie and which should not be used in
  production environments.

- Streaming Protocol  
  Allows the socket’s Send operation to return a message with the original `InputStream` as payload.

- XML Message Protocol  
  Use this protocol to read streaming XML documents. The only requirement is that each document
  includes an XML declaration at the beginning of the document in the form of `<?xml…​.`.  
  Data is read until a new document is found or until there is no more currently available data. For
  slower networks, `XmlMessageEofProtocol` might be more reliable.  
  Also, because the default character encoding for the platform is used to decode the message bytes
  when looking for the XML declaration, some caution with message character encodings is warranted.

- XML Message EOF Protocol  
  Extends `XmlMessageProtocol` to continue reading until either a new message or EOF is found.

- Custom Protocol  
  Define your own custom protocol by writing a class that extends `TcpProtocol`.

### Configure TCP Protocols for the Sockets Listener

To configure supported TCP protocols for the Sockets Listener:

1.  Open the **Global Element Properties** configuration of the Sockets Listener.

2.  On the **General** tab, for **Connection** select `Tcp listener`.

3.  In the **General** section of the **General** tab, for **Protocol** select one of the supported
    protocols.

4.  Set the required fields for the connector.

5.  Click **Test Connection** to confirm that Mule can connect with the specific server.

6.  Click **OK**.

In Studio, configuring the Sockets Listener to use Direct Protocol looks like this:

![Sockets Direct Protocol Configuration](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-tcp1-configuration.png)

Figure 6. Sockets Direct Protocol Configuration

In the **Configuration XML** tab, the XML looks as follows:

```xml
	<sockets:listener-config name="Sockets_Listener_config" >
		<sockets:tcp-listener-connection host="localhost" port="8082" >
			<sockets:protocol>
				<sockets:direct-protocol />
			</sockets:protocol>
		</sockets:tcp-listener-connection>
	</sockets:listener-config>
```

### Configure TCP Protocols for Send and Receive Operations

To configure supported TCP protocols for either the Send operation or the Send and receive
operation:

1.  Open the **Global Element Properties** configuration of your Sockets operation.

2.  On the **General** tab, for **Connection** select `Tcp requester`.

3.  On the **Connection** tab, for **Protocol** select one of the supported protocols.

4.  Set the required fields for the connector.

5.  Click **Test Connection** to confirm that Mule can connect with the specific server.

6.  Click **OK**.

In Studio, configuring the Send operation to use Direct Protocol looks like this:

![Sockets Direct Protocol Configuration](/mulesoft/current/en-us/sockets-connector/latest/_images/socket-tcp2-configuration.png)

Figure 7. Sockets Direct Protocol Configuration

In the **Configuration XML** tab, the XML looks like this:

```xml
<sockets:request-config name="Sockets_Send_config" >
	<sockets:tcp-requester-connection >
		<sockets:protocol >
			<sockets:direct-protocol />
		</sockets:protocol>
	</sockets:tcp-requester-connection>
</sockets:request-config>
```

## View the App Log

To check for problems, you can view the app log:

- If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio
  console window.

- If you’re running the app using Mule from the command line, the app log is visible in your OS
  console.

Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the
app log in the default location `MULE_HOME/logs/<app-name>.log`.

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Using Anypoint Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio)

- [Sockets Connector Reference](https://docs.mulesoft.com/sockets-connector/latest/sockets-documentation)

- [Salesforce Help](https://help.salesforce.com)
