Skip to main content

MQTT

Deployment

  1. Select MQTT protocol, and then click on "Next Step".

    Choose MQTT

  2. Fill in device name, device manufacturer, device type, and device model. The device name is the identifier used to distinguish different devices in Shifu Cloud. And then click on "Next Step".

    Enter device information

  3. Enter the IP address of the device you want to connect to.

    Enter device information

  4. Input the API method, API interface, and MQTT topic. Add at least one API to generate the API specification file, where the API methods include GET and POST. For MQTT, the same API cannot bind to 2 different MQTT Topic. For example, if you have an API named api1, and link it to MQTT Topic /topic1 with HTTP GET. Do not add a new api with API name api1 and MQTT Topic /topic2.

    Enter API information

  5. After adding the API, copy and paste the command from the pop-up to deploy the device into your Kubernetes cluster.

    Deploy device

    Deploy command

Usage

  1. Use kubectl get pods -A to view device deployment status.

    View device status

  2. To access the deviceshifu-mosquitto-service running in the deviceshifu namespace, use the following command to forward a local port to the service port: kubectl port-forward service/deviceshifu-mosquitto-service -n deviceshifu 3000:80

    Port forward

  3. Access the deviceshifu Mosquitto service via http://localhost:3000/value, and use curl to perform read and write operations separately.

  4. List all pods in the devices namespace to identify the running Mosquitto pod, then execute a command in that pod to subscribe to a specific topic and verify message reception.

    Access device

    Access device