Rate this page:

How to create outbound WebSocket connections

Our platform provides the WebSocket module for the communication between a client and a third-party service in real-time. With this module, you can create outbound WebSocket connections and send data through them.

Creating an outbound connection

The first thing you should do is create a WebSocket object using the VoxEngine.createWebSocket method. It accepts 2 parameters: URL in the format of 'wss: // + domain + path' and protocols (optional).

When it's done, you can send data via the WebSocket using the call.sendMediaTo method.

See the picture below to learn how it all works:


The code for your "OutboundWebSocket" scenario will look like this:

Outbound WebSocket

Outbound WebSocket

Learn more about setting up the Voximplant side (application, rule, user) and the server side at How to send call audio via WebSocket.