How do I publish and subscribe through MQTT in two PC connected in the same network through LAN with Publisher and Subscriber in different PC. I have my PC connected to same network interface (ethernet) with Ubuntu as is operating system.
To test, on subscribing pc i put the command mosquitto_sub -h localhost -t topic_name
and on the publisher pc mosquitto_pub -h subscriber_ip -t topic_name -m message
. This returns an error, connection refused
or sometimes network is unreachable
.
How can I resolve this?