I have a windows 11 PC running mosquitto –v –c my.conf
I have set the following in my.conf:
listener 1883 0.0.0.0
Wifi listener’s can here Wifi pub. and local host listener’s can here local host pub to the same “topic”.
Neither types can here the other type. How can I get Wifi and local to talk to each other?
Your configuration looks fine, but I am not 100% sure what you describe.
0.0.0.0 specifies that the MQTT broker will listen on all available network interfaces. In other words, it will accept connections from any IP address assigned to the machine, making the broker accessible from any device on the network. So you should be good here.
You also describe that you can publish from the local host and other clients in your local wifi to topics on the broker. Is that right?
If you are able to publish to certain topics you should also be able to subscribe to them.
With MQTT you have a broker which does the work. There are no direct connections between clients, only to the broker. The broker redirects messages to clients based on their subscriptions.
Can you explain a little more about what the problem is? Because from my perspective if you are able to publish, you should also be able to subscribe to topics and therefore get messages from the localhost to the Wifi clients.
Sorry I was not clear. Thanks for your help.
My setup looks like this:
Windows 11 running:
Mosquitto –v –c my.conf (BROKER)
Mosquitto_sub –t “topic”
Mosquitto_pub –t “topic” –m “this is a test”
Phone Running Wifi, MQTTool on 192.168.6 port 1883 “topic”
Micro controller Wifi, on 192.168.6 (sends message to “topic” approx. every 3 seconds) (at this time the micro only publishes.
I would like to add that this was working perfect a few days ago, however, when I rebooted the pc and started everything running I get the following problem (I have repeated this several time with the same results).
The phone gets the message from the micro controller over Wifi just as you would expect.
The Mosquitto_sub running on the windows PC does not receive the micro controller message.
If I publish a message from windows 11 mosquitto_pub the windows 11 mosquitto_sub get the message as expected . The phone does not get the message.
It’s like the Wifi is running one topic and the PC connected stuff is running a different topic. In all cases “topic” is the topic.
One more thing, I removed the 0.0.0.0 from the config file, no change in the results.
I can´t think of a good reason why this should be happening.
The only solution I can come up with is that you are running not one but two brokers, and the devices connect to different brokers! The windows package installs and starts a Mosquitto service, so that is probably still running.
If a topic arrives at a broker and there is a subscription to the topic, the broker will send the message.
You could double-check your broker logs, maybe even add “log_type all” to your configuration and see what clients are connecting. Do you see all three clients connecting there?
Another possibility is that you may be using double client IDs, and your clients are kicking each other from the broker reconnecting right after. So they would never be subscribed at the same time the message would be published.
Thanks again, I was running 2 Brokers, however, I’m not sure how that happened. I removed one of the brokers using the task manager and it started working correctly. I did a cold boot (all power off on pc) and the problem did not repeat.
Again Thanks for the great help!