Skip to main content



      Home
Home » Eclipse Projects » Paho » mqtt paho different than mosquitto_sub
mqtt paho different than mosquitto_sub [message #1857800] Sun, 26 February 2023 13:33 Go to next message
Eclipse UserFriend
I publish message using:
client.publish(topic_pub, payload, retain=True)


I can see most recent message and also previous messages with `mosquito_sub`:

# mosquitto_sub -t 'proxies/#'
{"datetime": "2023-02-25 09:01:42", "erf_endpoint": "us-ca101.sugar.net", "erf_ipaddr": "107.150.28.85"}
{"datetime": "2023-02-25 08:37:31", "erf_endpoint": "us-ca101.sugar.net", "erf_ipaddr": "6.6.1.1"}
{"datetime": "2023-02-26 08:33:11", "erf_endpoint": "us-nj3.sugar.net", "erf_ipaddr": "100.2.3.4"}



However, when I use paho mqtt I'm only seeing the older messages, not the most recent.
def mqtt_on_connect(client, userdata, flags, rc):
    client.subscribe(topic_sub)

def mqtt_on_message(client, userdata, msg):
    messages.append(msg)
    client.disconnect()

 client = mqtt.Client()
 client.on_connect = mqtt_on_connect
 client.on_message = mqtt_on_message
 client.connect(mqtt_broker)
 client.loop_forever()


{"datetime": "2023-02-25 09:01:42", "erf_endpoint": "us-ca101.sugar.net", "erf_ipaddr": "107.150.28.85"}
{"datetime": "2023-02-25 08:37:31", "erf_endpoint": "us-ca101.sugar.net", "erf_ipaddr": "6.6.1.1"}



What am I doing wrong here?
Re: mqtt paho different than mosquitto_sub [message #1857868 is a reply to message #1857800] Thu, 02 March 2023 11:18 Go to previous message
Eclipse UserFriend
You will not get an answer unless you provide more information.
Eg. you MUST provide the -v flag to mosquitto_sub to show the topics involved, and
you MUST show entire source code that does not work.
Good luck.
Previous Topic:Extract and graph an integer of binary data from mqtt topic.
Next Topic:Paho MQTT C++ support for http proxy
Goto Forum:
  


Current Time: Sat Jun 21 14:28:04 EDT 2025

Powered by FUDForum. Page generated in 0.03320 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top