Enable WebSocket service
The Websocket service provides a simple way for a Pulsar client to interact with a Pulsar cluster using languages that do not have an official client library, such as Java, Python, C++, and so on.
This document describes how to enable the WebSocket service on the Pulsar broker, Pulsar proxy, or both of them. Therefore, your client can connect to your Pulsar cluster through the WebSocket API.
If your Pulsar client directly communicates with your Pulsar cluster through the Pulsar broker, you only need to enable the WebSocket service on the Pulsar broker.
To enable the WebSocket service, you can set broker.configData.webSocketServiceEnabled
to true
in the values.yaml
YAML file as follows and use the helm upgrade
command to update the resource.
-
Enable the WebSocket service.
This example shows how to enable the WebSocket service on the Pulsar broker without enabling TLS encryption. If you do not enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket protocol and the port
9090
.This example shows how to enable the WebSocket service on the Pulsar broker with TLS encryption enabled. If you do enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket Secure (WSS) protocol and the port
9443
.- [1]
tls.enabled
: enable TLS encryption. For details, see enable TLS encryption on StreamNative Platform components. - [2]
tls.broker.enabled
: enable TLS encryption on the Pulsar broker. For details, see enable TLS encryption on StreamNative Platform components. - [3]
broker.configData.webSocketServiceEnabled
: enable the WebSocket service on the Pulsar broker.
- [1]
-
Apply the new configuration.
If your Pulsar client directly communicates with your Pulsar cluster through the Pulsar broker, you only need to enable the WebSocket service on the Pulsar broker.
To enable the WebSocket service, you can set broker.configData.webSocketServiceEnabled
to true
in the values.yaml
YAML file as follows and use the helm upgrade
command to update the resource.
-
Enable the WebSocket service.
This example shows how to enable the WebSocket service on the Pulsar broker without enabling TLS encryption. If you do not enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket protocol and the port
9090
.This example shows how to enable the WebSocket service on the Pulsar broker with TLS encryption enabled. If you do enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket Secure (WSS) protocol and the port
9443
.- [1]
tls.enabled
: enable TLS encryption. For details, see enable TLS encryption on StreamNative Platform components. - [2]
tls.broker.enabled
: enable TLS encryption on the Pulsar broker. For details, see enable TLS encryption on StreamNative Platform components. - [3]
broker.configData.webSocketServiceEnabled
: enable the WebSocket service on the Pulsar broker.
- [1]
-
Apply the new configuration.
If your Pulsar client directly communicates with your Pulsar cluster through the Pulsar proxy, you only need to enable the WebSocket service on the Pulsar proxy.
To enable the WebSocket service, you can set proxy.websocket.enabled
to true
in the values.yaml
YAML file as follows and use the helm upgrade
command to update the resource.
-
Enable the WebSocket service.
This example shows how to enable the WebSocket service on the Pulsar proxy without enabling TLS encryption. If you do not enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket protocol and the port
9090
.This example shows how to enable the WebSocket service on the Pulsar proxy with TLS encryption enabled. If you do enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket Secure (WSS) protocol and the port
9443
.- [1]
tls.enabled
: enable TLS encryption. For details, see enable TLS encryption on StreamNative Platform components. - [2]
tls.proxy.enabled
: enable TLS encryption on the Pulsar proxy. For details, see enable TLS encryption on StreamNative Platform components. - [3]
proxy.websocket.enabled
: enable the WebSocket service on the Pulsar proxy.
- [1]
-
Apply the new configuration.
If your Pulsar clients communicate with your Pulsar cluster through both the Pulsar broker and Pulsar proxy, you need to enable the WebSocket service on both the Pulsar broker and Pulsar proxy.
To enable the WebSocket service, you can set broker.configData.webSocketServiceEnabled
and proxy.websocket.enabled
to true
in the values.yaml
YAML file as follows and use the helm upgrade
command to update the resource.
-
Enable the WebSocket service.
This example shows how to enable the WebSocket service on the Pulsar broker and Pulsar proxy without enabling TLS encryption. If you do not enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket protocol and the port
9090
.This example shows how to enable the WebSocket service on the Pulsar broker and Pulsar proxy with TLS encryption enabled. If you do enable TLS encryption, your client will connect to a Pulsar cluster through the WebSocket Secure (WSS) protocol and the port
9443
.- [1]
tls.enabled
: enable TLS encryption. For details, see enable TLS encryption on StreamNative Platform components. - [2]
tls.proxy.enabled
: enable TLS encryption on the Pulsar proxy. For details, see enable TLS encryption on StreamNative Platform components. - [3]
tls.broker.enabled
: enable TLS encryption on the Pulsar broker. For details, see enable TLS encryption on StreamNative Platform components. - [4]
proxy.websocket.enabled
: enable the WebSocket service on the Pulsar proxy. - [5]
broker.configData.webSocketServiceEnabled
: enable the WebSocket service on the Pulsar broker.
- [1]
-
Apply the new configuration.