Get server timestamp HiveMQ CLOUD

Hi, I’m trying to receive the Server Timestamp that is created when a message arrives at the HiveMQ Cloud Broker.
My code looks like this:
def on_message(client, userdata, msg):
print("Timestamp: " + str(msg.timestamp))
The timestamp format should be in a UTC 64 Bit integer Unix Epoch timestamp format.
But i only receive the timestamp as “Timestamp: 2.876988916”. So it looks like a weird float number that i’m not able to interpret.
Does anyone know what is happening here or how i can receive the server timestamp?
I was already trying formatting the received value into several other formats or datatypes but im not able to get a proper value
Greeting and thanks in advance

Hello @ktpn ,

Thank you for the outreach, and welcome to the HiveMQ Community!

Could you please provide the client library that is currently being used as well so we can best assist? This will allow for a bit more understanding of the flow for messages when subscribing to a topic, as well as more information regarding time-stamping.

One additional item to confirm - some publishing devices, such as sensors, publish their own timestamps as part of a message packet. I wanted to verify that we are looking to obtain a timestamp for the message delivery itself, rather than a timestamp contained within the message payload.

Aaron from HiveMQ Team

Hi @AaronTLFranz,
Thanks for your quick response.
I wanna calculate the latency between sending and receiving my messages from the client to the server.
I’m using the paho-mqtt client library for the consumer and the com.hivemq.client.mqtt.mqtt5 Library for the the actual publishing client on AAOS.
I already looked at the paho implementation and found a “time_func = time.monotonic” implementation. But calculating the monotonic time didnt really worked for me.
Paho and HiveMQ Library are using the MQTTMessage.timestamp value that should be inserted on the Broker side as soon as the message arrives (Should be the value that can be seen in the Cloud UI aswell).

And yes, i’ve already added some timestamp values to my payload but i’m looking for the message delivery timestamp that is created on the broker side.


Hello @ktpn ,

Thank you for the follow-up and additional details!

One point to clarify - the HiveMQ Broker does not append timestamps to messages when submitting a message from the HiveMQ Broker to a subscribing client. That said, the Paho client library does generate a timestamp, though this is done outside of the broker.

If using MQTT5, one way to implement a timestamp that would be traceable through the entire pipeline (i.e. from publish, to the broker, and then to subscribing client) would be to submit the timestamp of the publish with a custom user property. More info on that can be found here.

Additionally, another user had a similar questions here on the community forum, and there may be further insights in the aforementioned thread, linked here.

Aaron from the HiveMQ Team