My Os is Windows 7,32bit.
I install mosquitto-1.1.2-install-win32.exe.
I don't change the mosquitto.conf
file,so no topic prefix setting.
Use Mosquitto to subscribe topic like(the subscription window):
mosquitto_sub.exe -q 2 -t mytopic
OR mosquitto_sub.exe -q 2 -t #
Use Mosquitto to publish a topic like(the publish window):
mosquitto_pub.exe -q 2 -t mytopic -m “hello″
Then in the subscription cmd window,I can receive "hello"
I have been following Dale Lane's blog and "Android MQTT example project" to access Mosquitto.
java client(MQTTDemo.java):
//i use mobile emulator
editor.putString(“broker”, "10.0.2.2″);
editor.putString(“topic”, "mytopic”);
//or editor.putString(“topic”, “#”); '#' match any topic
I test connectToBroker()
in MQTTService.java
, the connection is OK.
I publish the topic "mytopic" again with Mosquitto.
But,finally I cannot receive the message in the mobile emulator.
Anybody know why or any other methods?
Thanks a lot!
Depends at times on how the broker is configured. There are ways within the Mosquitto broker to specify a topic prefix on a per-channel basis. At other times, the subscription topic needs to be specified as generic. I'm not sure if either of these apply in your situation, but there are easy diagnostics and you do not describe using them so I'll offer them as a starting point.
#
and then look at the topic strings that you receive.#
before testing any publications. If I get the publication in the GUI but not the app it points to a different problem set than if I don't get anything at all.A better description of the problem will include some of this differential diagnostic. If you get the chance, please re-test and edit the question with the results.