Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » mqtt paho different than mosquitto_sub
mqtt paho different than mosquitto_sub [message #1857800] Sun, 26 February 2023 18:33 Go to next message
Mi Van is currently offline Mi VanFriend
Messages: 2
Registered: February 2023
Junior Member
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 16:18 Go to previous message
Gambit Support is currently offline Gambit SupportFriend
Messages: 46
Registered: March 2019
Member
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: Wed Apr 24 21:58:07 GMT 2024

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

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

Back to the top