Search code examples
mqttmosquittoemq

Mosquitto client can't publish message to EMQ X Broker


I have model like this: enter image description here

EMQ X Broker installed at IP 222.x.y.z.

And two Mosquitto client.

I want to publish message from Mosquitto_client_2 then receive Mosquitto_client_1.

I do like this:

Step 1: run command:

mosquitto_sub -h 222.x.y.z -t "TEST_TEST"

on Client_1

enter image description here

Step 2: EMQ X Broker auto create topic "TEST_TEST", like this enter image description here

Step 3: Mosquitto client 2 publish message, run command:

mosquitto_pub -h 222.x.y.z -t TEST_TEST -m "hello world"

But it have problem "Error: Connection refused" like this: enter image description here

I don't know the cause of the error and how to fix this error.

P/s: I also open all port for EMQ X. enter image description here


Solution

  • You should first eliminate the network problem and use telnet to determine whether the port can be accessed.

    telnet localhost 1883
    
    Trying ::1...
    telnet: connect to address ::1: Connection refused
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.