Contact Us 1-800-596-4880

WebSockets Connector in CloudHub - Mule 4

You can deploy Mule apps that contain inbound WebSockets endpoints, outbound WebSockets endpoints, or both to CloudHub.

If your app has inbound WebSockets endpoints only, to deploy the app in CloudHub you must:

  1. Configure an Anypoint Virtual Private Cloud (VPC).

  2. Set up a dedicated load balancer to route WS and WSS traffic through the Mule app.

To set up the inbound WebSocket endpoints:

  1. Configure the WebSockets inbound listener (<ws:inbound-listener>) to listen on one of the following ports:

    • 0.0.0.0.

    • To communicate over WS, set the listener port to 8091.

    • To communicate over WSS, set the listener port to 8092.

  2. Deploy your app to the VPC.

  3. Set up the dedicated load balancer’s URL mapping rules to associate a URI to a specific app.

    For example, if your app is named 'my-websockets-mule-app', you can define a rule like the following:

    • Input Path: /my-websockets-mule-app/

    • Target App: my-websockets-mule-app

    • Output Path: /

    • Protocol: ws

This rule routes all requests made to your dedicated load balancer’s URL and the specified input path to your Mule app’s root path /. The load balancer’s name determines its assigned URL, so for this example, if you name your load balancer mylb, then you would need to browse to: ws://mylb.lb.anypointdns.net:80/my-websockets-mule-app/ to connect to your WebSockets Listener.

The dedicated load balancer forwards all requests issued to port 80 to your app’s port 8091, which is destined for all WS connections. When using WSS, however, issue your requests to port 443, and these requests are forwarded to your Mule app’s port 8092.

View on GitHub