This document describes how to connect to a cluster through a WebSocket API, and use the WebSocket producer and consumer to produce and consume messages to and from a topic. The WebSocket API supports connecting to a StreamNative cluster using API Keys authentication.
To use the WebSocket API to connect to a StreamNative cluster, you need to enable the WebSocket service in advance. For details, see enable WebSocket service.
This document assumes that you have created a StreamNative cluster and a service account, and have granted the service account produce
and consume
permissions to the namespace for the target topic.
Use the pip install websocket-client
command to install all dependencies. For details, see the Pulsar WebSocket documentation.
To connect a StreamNative cluster using API keys, follow these steps.
To get the service URL(s) of a StreamNative cluster, follow these steps.
Navigate to the Cluster Dashboard page by switching to the cluster workspace.
On the Cluster Dashboard page, click Details tab.
You will see the available service URLs in the Access Points area.
You can click Copy at the end of the row of the service URL that you want to use.
Navigate to the Cluster Dashboard page by switching to the cluster workspace.
On the Cluster Dashboard page, click Details tab.
You will see the available service URLs in the Access Points area.
You can click Copy at the end of the row of the service URL that you want to use.
Before using an API key, verify that the service account is authorized to access the resources, such as tenants, namespaces, and topics.
You can follow the instructions to create an API key for the service account you choose to use.
${apikey}
: an API key of your service account.${apikey}
: an API key of your service account.CLUSTER_HOST
with the domain name of the cluster. To get the domain name of the target cluster, click Manage > Cluster on the StreamNative Cloud Console.443
.This document describes how to connect to a cluster through a WebSocket API, and use the WebSocket producer and consumer to produce and consume messages to and from a topic. The WebSocket API supports connecting to a StreamNative cluster using API Keys authentication.
To use the WebSocket API to connect to a StreamNative cluster, you need to enable the WebSocket service in advance. For details, see enable WebSocket service.
This document assumes that you have created a StreamNative cluster and a service account, and have granted the service account produce
and consume
permissions to the namespace for the target topic.
Use the pip install websocket-client
command to install all dependencies. For details, see the Pulsar WebSocket documentation.
To connect a StreamNative cluster using API keys, follow these steps.
To get the service URL(s) of a StreamNative cluster, follow these steps.
Navigate to the Cluster Dashboard page by switching to the cluster workspace.
On the Cluster Dashboard page, click Details tab.
You will see the available service URLs in the Access Points area.
You can click Copy at the end of the row of the service URL that you want to use.
Navigate to the Cluster Dashboard page by switching to the cluster workspace.
On the Cluster Dashboard page, click Details tab.
You will see the available service URLs in the Access Points area.
You can click Copy at the end of the row of the service URL that you want to use.
Before using an API key, verify that the service account is authorized to access the resources, such as tenants, namespaces, and topics.
You can follow the instructions to create an API key for the service account you choose to use.
${apikey}
: an API key of your service account.${apikey}
: an API key of your service account.CLUSTER_HOST
with the domain name of the cluster. To get the domain name of the target cluster, click Manage > Cluster on the StreamNative Cloud Console.443
.