Pulsar WebSocket API
Pulsar WebSocket API provides a simple way to interact with Pulsar using languages that do not have an official client library. Through WebSocket, you can publish and consume messages and use features available on the Client Features Matrix page.
You can use Pulsar WebSocket API with any WebSocket client library. See examples for Python and Node.js below.
Running the WebSocket service
The standalone variant of Pulsar that we recommend using for local development already has the WebSocket service enabled.
In non-standalone mode, there are two ways to deploy the WebSocket service:
- embedded with a Pulsar broker
- as a separate component
Embedded with a Pulsar broker
In this mode, the WebSocket service will run within the same HTTP service that's already running in the broker. To enable this mode, set the webSocketServiceEnabled
parameter in the conf/broker.conf
configuration file in your installation.
webSocketServiceEnabled=true
As a separate component
In this mode, the WebSocket service will be run from a Pulsar broker as a separate service. Configuration for this mode is handled in the conf/websocket.conf
configuration file. You'll need to set at least the following parameters:
Here's an example:
configurationStoreServers=zk1:2181,zk2:2181,zk3:2181
webServicePort=8080
clusterName=my-cluster