> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamnative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure MoP

[MQTT on Pulsar (MoP)](https://github.com/streamnative/mop) is a protocol handler developed by StreamNative to natively support the MQTT protocol on the Pulsar broker. By adding the MoP protocol handler to your existing Pulsar cluster, you can now migrate your existing MQTT applications and services to Pulsar without modifying the code.

## Enable MoP

This section describes how to enable MoP on StreamNative Platform.

### Prerequisites for enabling MoP

* `sn-platform` chart: 1.4.0 or higher
* `pulsar-operator` chart: 0.10.0 or higher

### Procedure

To enable MoP within a Kubernetes cluster, you can set `broker.mop.enabled` and `broker.mop.proxyEnabled` to `true` in the `values.yaml` YAML file as follows and use the `helm upgrade` command to update the resource.

1. Enable MoP.

   ```yaml theme={null}
   broker:
     mop:
       enabled: true
       proxyEnabled: true
   ```

2. (Optional) If you want to enable authentication and authorization, set the `broker.mop.authenticationEnabled` and `broker.mop.authorizationEnabled` to `true` in the `values.yaml` YAML file as follows.

<Note title="Note">
  MoP inherits all the authentication and authorization methods from the Pulsar broker configurations.
</Note>

```yaml theme={null}
broker:
  mop:
    enabled: true
    # -- enable token authentication
    authenticationEnabled: true
    # -- enable authorization
    authorizationEnabled: true
```

3. Apply the new configuration.

   ```bash theme={null}
   helm upgrade -f /path/to/your/values.yaml <release_name> streamnative/sn-platform -n <k8s_namespace>
   ```

## Connect to your Pulsar cluster using Eclipse Mosquitto

You can use any client that supports the MQTT protocol to publish data into Pulsar. This section shows how to use the [Eclipse Mosquitto](https://mosquitto.org/) MQTT CLI tool to connect to a Pulsar cluster and then produce and consume messages to and from the Pulsar cluster.

### Prerequisites

* Install StreamNative Platform and run a Pulsar cluster. For details, see [deploy StreamNative Platform](/private-cloud/v1/operating-streamnative-platform/deploy/sn-deploy).
* Enable MoP. For details, see [enable MoP](#enable-mop).
* Get the Web service URL of your Pulsar cluster or broker service and the token used to access your Pulsar cluster. For details, see [prepare to connect to Pulsar clusters](/private-cloud/v1/build/connect-prepare).

### Steps

To connect to a Pulsar cluster using the [Eclipse Mosquitto](https://mosquitto.org/) MQTT CLI tool, follow these steps.

1. Deploy an Eclipse Mosquitto Pod.

   a. Define an Eclipse Mosquitto as below and save the YAML file (`pod.yaml`).

   ```yaml theme={null}
   apiVersion: v1
   kind: Pod
   metadata:
     name: mosquitto
     labels:
       app: mosquitto
   spec:
     containers:
       - name: mqtt-cli
         image: eclipse-mosquitto
         imagePullPolicy: IfNotPresent
         command:
           - sleep
           - 3600s
   ```

   b. Apply your configurations.

   ```bash theme={null}
   kubectl apply -f pod.yaml
   ```

2. Subscribe to messages from the Pulsar cluster.

   a. Open a new terminal window and enter the Eclipse Mosquitto Pod.

   ```bash theme={null}
   kubectl exec -it mosquitto -- sh
   ```

   b. Subscribe to messages from the Pulsar cluster.

   ```bash theme={null}
   mosquitto_sub -h <broker_service> -p 5682 -t <topic_name>
   ```

   If you have enabled authentication, use the token as the password. The username can be any string.

   ```bash theme={null}
   mosquitto_sub -h <broker_service> -p 5682 -u mqtt -P <token> -t <topic_name>
   ```

3. Publish messages to the Pulsar cluster.

   a. Open a new terminal window and enter the Eclipse Mosquitto Pod.

   ```bash theme={null}
   kubectl exec -it mosquitto -- sh
   ```

   b. Publish messages to the Pulsar cluster.

   ```bash theme={null}
   mosquitto_pub -h <broker_service> -p 5682 -t <topic_name> -m "hello pulsar"
   ```

   If you have enabled authentication, execute the following command.

   ```bash theme={null}
   mosquitto_pub -h <broker_service> -p 5682 -u mqtt -p <token> -t <topic_name> -m "hello pulsar"
   ```
