0

I am new to MQTT and I am trying to send a basic message from client to broker using the command prompt. I have downloaded the mqtt for both client and broker and I could not publish the message to the subsriber as it has connection refused problem. below and the command i run for both subsriber and publisher.

subsriber command(no error here): mosquitto_sub -t topic/example

publisher command(connection refused): mosquitto_pub -h 192.168.1.196 -t topic/example -m "This is the first message sent via MQTT from the Edge to the Cloud server"

I have try to add the port inside the command but it is not working as well

After execute the command at the publisher side, I should be able to see the message sent by the publisher. But at this case, it has problem with the connection.

KamHeng
  • 1
  • 1
  • With the [default config](https://mosquitto.org/documentation/migrating-to-2-0/#listener-behaviour-changes) mosquitto (the broker I'm assuming you are using) only accepts connections from the local machine. You will need to create a [`mosquitto.conf`](https://mosquitto.org/documentation/migrating-to-2-0/#listener-behaviour-changes) (if you have already done this then please share it with us). – Brits Jun 24 '23 at 08:56

0 Answers0