This example shows how to use the WebSocket API to connect to a Pulsar cluster and then produce and consume messages to and from the Pulsar cluster.
This document assumes that you have created a service account, and have granted the service account produce and consume permissions to the namespace for the target topic.
To use the WebSocket API to connect to a Pulsar cluster, you need to enable the WebSocket service in advance. For details, see enable WebSocket service.
If Web Socket Secure (WSS) protocol is used, you should use the port 9443.