The following sections walk you through a sample scenario that demonstrates how to send a message from a WebSocket client to a WebSocket endpoint via WSO2 ESB:
If you need to send a message from a WebSocket client to a WebSocket endpoint via WSO2 ESB, you need to establish a persistent Websocket connection from the WebSocket client to WSO2 ESB as well as from WSO2 ESB to the WebSocket back-end.
To demonstrate this scenario, you need to create two dispatching sequences. One for the client to back-end mediation, and another for the back-end to client mediation. Finally you need to configure WSO2 ESB's WebSocket inbound endpoint to use the created sequences and listen on port 9091.
- Start the WSO2 ESB server. For information on how to start the ESB server. see Running the Product.
- Download the sample netty artifacts folder.
Configuring the sample scenario
Create the sequence for client to back-end mediation as follows:
Create the sequence for back-end to client mediation as follows:
Configure WSO2 ESB's WebSocket inbound endpoint as follows to use the created sequences and listen on port 9091:
Executing the sample scenario
Execute the following command to start the WebSocket client:
Analyzing the output
If you analyze the log, you will see that a connection from the WebSocket client to WSO2 ESB is established, and the sequences are executed by the WebSocket inbound endpoint.
You will also see that the message sent to the WebSocket server is not transformed, and that the response injected to the out sequence is also not transformed.