Skip to content

Websocket Inbound Endpoint

Introduction

The WebSocket Inbound protocol is based on the Websocket protocol and allows full-duplex message mediation.

Syntax

<inboundEndpoint name="WebSocketListenerEP" onError="fault" protocol="ws" sequence="TestIn" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
  <parameters>
     <parameter name="inbound.ws.port">9091</parameter>
     <parameter name="ws.outflow.dispatch.sequence">TestOut</parameter> 
     <parameter name="ws.client.side.broadcast.level">0</parameter>
     <parameter name="ws.outflow.dispatch.fault.sequence">fault</parameter>
  </parameters> 
</inboundEndpoint>
<inboundEndpoint name="SecureWebSocketEP" onError="fault" protocol="wss" sequence="TestIn" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
  <parameters>
     <parameter name="inbound.ws.port">9091</parameter>
     <parameter name="ws.client.side.broadcast.level">0</parameter>
     <parameter name="ws.outflow.dispatch.sequence">TestOut</parameter>
     <parameter name="ws.outflow.dispatch.fault.sequence">fault</parameter>
     <parameter name="wss.ssl.key.store.file">repository/resources/security/wso2carbon.jks</parameter>
     <parameter name="wss.ssl.key.store.pass">wso2carbon</parameter>
     <parameter name="wss.ssl.trust.store.file">repository/resources/security/client-truststore.jks</parameter>
     <parameter name="wss.ssl.trust.store.pass">wso2carbon</parameter>
     <parameter name="wss.ssl.cert.pass">wso2</parameter>
   </parameters>
</inboundEndpoint>

Properties

Listed below are the properties used for creating a Websocket inbound endpiont.

Required Properties

The following properties are required when creating a Websocket inbound endpiont.

Property Description
inbound.ws.port The netty listener port on which the WebSocket inbound listens.
ws.client.side.broadcast.level The client broadcast level that defines how WebSocket frames are broadcast from the WebSocket inbound endpoint to the client. Broadcast happens based on the subscriber path client connected to the WebSocket inbound endpoint. The three possible levels are as follows:
0 - Only a unique client can receive the frame from a WebSocket inbound endpoint.
1 - All the clients connected with the same subscriber path receives the WebSocket frame.
2 - All the clients connected with the same subscriber path, except the one who publishes the frame to the inbound, receives the WebSocket frame.
ws.outflow.dispatch.sequence The sequence for the back-end to client mediation.
ws.outflow.dispatch.fault.sequence The fault sequence for the back-end to client mediation path.
sequential The behavior when executing the given sequence.
When set as true , mediation will happen within the same thread. When set as false , the mediation engine will use the inbound thread pool. The default thread pool values can be found in the MI_HOME/conf/deployment.toml file, under the `[mediation]` section. The default setting is true.
Suspend If the inbound listener should pause when accepting incoming requests, set this to true. If the inbound listener should not pause when accepting incoming requests, set this to false.

Required Properties (for Secured Websocket)

In addition to the common websocket inbound properties listed above, the following properties are required when creating a secured Websocket inbound endpiont.

Property Description
inbound.ws.port The netty listener port on which the WebSocket inbound listens.
ws.client.side.broadcast.level The client broadcast level that defines how WebSocket frames are broadcast from the WebSocket inbound endpoint to the client. Broadcast happens based on the subscriber path client connected to the WebSocket inbound endpoint. The three possible levels are as follows:
0 - Only a unique client can receive the frame from a WebSocket inbound endpoint.
1 - All the clients connected with the same subscriber path receives the WebSocket frame.
2 - All the clients connected with the same subscriber path, except the one who publishes the frame to the inbound, receives the WebSocket frame.
ws.outflow.dispatch.sequence The sequence for the back-end to client mediation.
ws.outflow.dispatch.fault.sequence The fault sequence for the back-end to client mediation path.
wss.ssl.key.store.file The keystore location where keys are stored.
wss.ssl.key.store.pass The password to access the keystore file.
wss.ssl.trust.store.file The truststore location where keys are stored.
wss.ssl.trust.store.pass The password to access the truststore file.
wss.ssl.cert.pass The SSL certificate password.

Optional Properties

The following optional properties can be configured when creating a Websocket inbound endpiont.

Property Description
ws.boss.thread.pool.size The size of the netty boss pool.
ws.worker.thread.pool.size The size of the worker thread pool.
ws.subprotocol.handler.class Specify one or more custom subprotocol handler classes that are required. Separate each custom subprotocol handler class using a semicolon.
ws.default.content.type Specifies the content type of the Web Socket frames that are received from the inbound endpoint.
ws.shutdown.status.code Specifies the status code of the closed web socket frame sent when the inbound endpoint is closed.
ws.shutdown.status.message Specifies the status message of the closed web socket frame when the inbound endpoint is closed.
ws.pipeline.handler.class The fully qualified class name of a pipeline handler class that you implemented.
Ws Use Port Offset

Optional Properties (for Secured Websocket)

The following optional properties can be configured when creating a Secured Websocket inbound endpiont.

Property Description
wss.ssl.protocols Enables the SSL protocol for the particular WebSocket inbound endpoint. Default value is "TLS". You can change it to a TLS version(s), which is/are enabled with the SSL protocol (i.e., TLSv1,TLSv1.1,TLSv1.2). For example, TLSv1.1,TLSv1.2
wss.ssl.cipher.suites

Enables the specified Cipher Suites for the particular WebSocket inbound endpoint. For example:

<parameter name="wss.ssl.cipher.suites">
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA
</parameter>
Top