Contact Us 1-800-596-4880

WebSockets Studio Configuration - Mule 4

To configure the connector in Anypoint Studio:

  1. Add the connector to a Studio project.

  2. Configure the connector.

  3. Configure an input source for the connector.

Add the Connector to a Studio Project

Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.

Add the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange icon (X) in the upper-left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "websockets".

  5. Select the connector and click Add to project.

  6. Follow the prompts to install the connector.

Add the Connector in Studio

  1. In Studio, create a Mule project.

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

  3. In Add Modules to Project, type "websockets" in the search field.

  4. Click this connector’s name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure the Connector

  1. Go to the Global Elements tab, and click Create.

  2. From Connector Configuration, select the WebSockets Config.

  3. If you want your connector to listen for incoming requests check the Configure Inbound WebSocket section.
    If you want to perform requests to external services, check the Configure Outbound WebSocket section.
    You can check both if your application will be doing both inbound and outbound connections.

Configure Inbound WebSockets

  1. Go to the Global Elements tab and click Create.

  2. From Connector Configuration, select the HTTP Listener Config.

  3. In your WebSockets Configuration, check the Server settings box.

  4. Specify the listener base path(optional) and reference the HTTP Listener Config you created before.

Configure Outbound WebSockets

  1. In your WebSockets Configuration, check the Client settings box.

  2. Specify the following optional properties:

    • Host

    • Port

    • Path

  3. In the Default Headers and Query Parameters sections you can introduce your default values for headers and query parameters by selecting an option from the drop-down list.

    1. Select Expression to enter a dwl expression.

    2. Click Edit Inline to enter key/value pairs by clicking the '+' sign.

Configure an Input Source

Configure an input source for the connector.

You can put the following operations for the connector in the Source area of the Studio canvas:

  • Inbound Listener

  • On Outbound Socket Message

  • On Inbound Connection (requires an Inbound Listener)

  • On Socket Closed

Next

Now that you have completed configuring Studio, see the Connector Configuration for more configuration ideas.

View on GitHub