processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.06k stars 1.51k forks source link

Inaccurate time stamp #3974

Closed mkassir95 closed 1 year ago

mkassir95 commented 1 year ago

time stamp is not correct it differs by some minutes from the real time I am using http://localhost:5281/api/get_last

image

badlop commented 1 year ago

That API command is implemented in https://github.com/processone/ejabberd/blob/d26a9d583f9c22ece39bc5bdb170154537cd94c7/src/mod_admin_extra.erl#L1447

When the account has an online session, the API command returns the current time, as provided by the functions:

xmpp_util:encode_timestamp(erlang:timestamp()).
<<"2023-01-09T15:50:28.363891Z">>

For example:

$ ejabberdctl get_last user1 localhost
2023-01-09T15:47:05.486570Z     ONLINE

$ ejabberdctl get_last user1 localhost
2023-01-09T15:47:06.068793Z     ONLINE

When the last session disconnects, then it returns the timestamp of that disconnection:

2023-01-09 16:47:12.774997+01:00 [info] (tls|<0.1424.0>)
 Closing c2s session for user1@localhost/tka1:
 Stream reset by peer

$ ejabberdctl get_last user1 localhost
2023-01-09T15:47:12Z    Stream reset by peer

Maybe the time in your server machine is wrong?

mkassir95 commented 1 year ago

@badlop thank you. Maybe I it is a time sycronization issue.