### Start Docker Environment Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/cmd/docker/readme.md Builds and starts the publisher, broker, and subscriber containers in the background. ```bash docker-compose up --build --detach ``` -------------------------------- ### Launch Mosquitto with configuration Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/fvt/README.md Start the Mosquitto broker using the specified configuration file from the fvt directory. ```bash /usr/bin/mosquitto -c ./mosquitto.cfg ``` -------------------------------- ### Install Paho MQTT Dependencies Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/README.md Install the required websocket and proxy packages for the client. ```bash go get github.com/gorilla/websocket go get golang.org/x/net/proxy ``` -------------------------------- ### Install Paho MQTT via GOPATH Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/README.md Use this command to install the library when not using Go modules. ```bash go get github.com/eclipse/paho.mqtt.golang ``` -------------------------------- ### Execute setup script for IBM MessageSight Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/fvt/README.md Run the provided shell script to configure the server objects required for unit tests. ```bash ./setup_IMA.sh ``` -------------------------------- ### Configure Library Logging Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/README.md Assign logging endpoints to the library to enable debug and error reporting. ```go func main() { mqtt.ERROR = log.New(os.Stdout, "[ERROR] ", 0) mqtt.CRITICAL = log.New(os.Stdout, "[CRIT] ", 0) mqtt.WARN = log.New(os.Stdout, "[WARN] ", 0) mqtt.DEBUG = log.New(os.Stdout, "[DEBUG] ", 0) // Connect, Subscribe, Publish etc.. } ``` -------------------------------- ### View Container Logs Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/cmd/docker/readme.md Displays logs for all containers or specifically for the subscriber container. ```bash docker-compose logs --follow ``` ```bash docker-compose logs --follow sub ``` -------------------------------- ### Verify IBM MessageSight endpoint configuration Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/fvt/README.md Check the status and details of the configured MQTT endpoint. ```text Console> imaserver show Endpoint Name=GoMqttEP1 Name = GoMqttEP1 Enabled = True Port = 17001 Protocol = MQTT Interface = all SecurityProfile = ConnectionPolicies = GoMqttCP1 MessagingPolicies = GoMqttMP1 MaxMessageSize = 1024KB MessageHub = GoMqttTestHub Description = ``` -------------------------------- ### Add SSH key to IBM MessageSight Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/fvt/README.md Use this command on the MessageSight console to enable passwordless SSH access. ```text Console> user sshkey add "scp://user@host:~/.ssh/authorized_keys" ``` -------------------------------- ### Simulate Network Connection Loss Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/cmd/docker/readme.md Disconnects and reconnects a container from the network to simulate connectivity issues. ```bash docker network disconnect lostpackets_test-net lostpackets_pub_1 docker network connect lostpackets_test-net lostpackets_pub_1 ``` -------------------------------- ### Stop Docker Environment Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/cmd/docker/readme.md Stops and removes the containers defined in the docker-compose configuration. ```bash docker-compose down ``` -------------------------------- ### Handle Asynchronous Publish Errors Source: https://github.com/eclipse-paho/paho.mqtt.golang/blob/master/README.md Check for errors in asynchronous publish operations using a goroutine. ```go t := client.Publish("topic", qos, retained, msg) go func() { _ = t.Wait() // Can also use '<-t.Done()' in releases > 1.2.0 if t.Error() != nil { log.Error(t.Error()) // Use your preferred logging technique (or just fmt.Printf) } }() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.