The following sections walk you through a sample scenario that demonstrates how to send a message from a HTTP client to a WebSocket endpoint via WSO2 ESB:
If you need to send a message from a HTTP client to a WebSocket endpoint via WSO2 ESB, you need to establish a persistent Websocket connection 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. Then you need to create a proxy service to call the created sequences.
- Start WSO2 ESB. For information on how to start the ESB server. see Running the Product.
- Download the sample netty artifacts folder.
Execute the following command to start the WebSocket server on port 8082:
Configuring the sample scenario
Create the sequence for client to back-end mediation as follows:
Create the sequence for the back-end to client mediation as follows:
Create a proxy service as follows to call the above sequences:
Executing the sample scenario
Execute the following command to invoke the proxy service:
Analyzing the output
If you analyze the log, you will see that a HTTP request is sent to the WebSocket server, and that the WebSocket server injects the response to the out sequence.