Web interface not updating position and other fields when passing timestamp [from fake device]

Antonis Gotsis6 years ago

Dear all,
I have created a fake device and successfully updating its status at the web interface by passing to 5055 the following fields: lat, lon, speed, alt.
When I am trying to add the timestamp although the POST requests seems fine (I get a 200 response code and the server-log also records the expected information sent by my fake device) I see no update in the Web interface.
An example taken from the server-log:

2018-08-30 17:52:47  INFO: [dc1426a1] connected
2018-08-30 17:52:47 DEBUG: [dc1426a1: 5055 < 147.102.25.70] HEX: 504f5354202f6170692f6465766963657320485454502f312e310d0a4163636570742d456e636f64696e673a206964656e746974790d0a436f6e74656e742d4c656e6774683a2039390d0a486f73743a203134372e3130322e32352e3131313a353035350d0a557365722d4167656e743a20507974686f6e2d75726c6c69622f322e370d0a436f6e6e656374696f6e3a20636c6f73650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a417574686f72697a6174696f6e3a204261736963206447567a644542305a584e304c6d4e76625470305a584e300d0a0d0a74696d657374616d703d323031382d30382d32345431373a34363a30382e3030305a26616c7469747564653d3234312e3137266c6f6e3d32332e383138393531363637266c61743d33382e3030373138333333332673706565643d302e302669643d32
2018-08-30 17:52:47 DEBUG: [dc1426a1: 5055 > 147.102.25.70] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-08-30 17:52:47  INFO: [dc1426a1] id: 2, time: 2018-08-24 20:46:08, lat: 38.00718, lon: 23.81895, course: 0.0

So the 1st part is the post request, and using the online traccar hex decoder I get:

POST /api/devices HTTP/1.1
Accept-Encoding: identity
Content-Length: 99
Host: 147.102.25.111:5055
User-Agent: Python-urllib/2.7
Connection: close
Content-Type: application/json
Authorization: Basic dGVzdEB0ZXN0LmNvbTp0ZXN0

timestamp=2018-08-24T17:46:08.000Z&altitude=241.17&lon=23.818951667&lat=38.007183333&speed=0.0&id=2

If I omit the timestamp field, the updating works smoothly.

Any Ideas?

Many thanks,
A./

Armstrong6 years ago

Hi, the timestamp should be a UNIX timestamp

Armstrong6 years ago

Hi, no idea why your timestamp is not parsed correctly, it should be.
Try with a UNIX timestamp, this works for sure.

Antonis Gotsis6 years ago

Thanks for your answer.

I've seen in other posts and in the documentation that we can also use the ISO-formatted UTC datetimes, but anyway, I changed that to epoch...

I am getting a really weird behavior now, while trying the unix epoch. Actually, if I use the system time (in python this is int(time.time()))), I am getting updated positions. However, if I pass a certain epoch corresponding to an old time (for example 1535132942), I am not getting any update. I have checked the data types and are exactly the same. Is it possible that old datetimes are omitted by traccar? By the way I am using the docker alpine 4.0 version for the server and a custom python-based client.

Thanks again,
A./

Armstrong6 years ago

Did you change database.historyDays ? Per the documentation:
"Number of days to store position and event history. By default Traccar doesn't clear any old data from the database."

Anton Tananaev6 years ago

I have just tested your original message and everything works fine. You can even see it in your log that it's decoded correctly.

Antonis Gotsis6 years ago

I don't disagree with that, I've also tested it with your online hex decoder. The issue was that the fake device was not shown in the web-interface when using old timestamps (not taken from the system time). I managed to understand why this happened. It seems that if you pass to the same device a datetime X, then any datetime passed which corresponds to an older time is ignored. Is this reasonable behavior? I created a new device with no passed timestamp, and my recorded path (containing old timestamps) was shown in the web interface.
A./

Anton Tananaev6 years ago

Web app obviously shows latest (by time) position.

Antonis Gotsis6 years ago

Yes, you are absolutely right.
Thanks,
A./