OSMAND request appears to take 1 minute to complete

Alan Lobo3 months ago

I have a script that fetches locations from third party APIs and then pushing it to traccar using OSMAND.
From the log, it appears that every request seems to take almost a minute. Just wanted to know if OSMAND is slow generally or is it a hardward issue ? although my VM is small, the health stats on it dont appear to be stressed.

**2024-06-06 17:27:39**  INFO: Event id: GA03K1338, time: 2024-06-06 17:27:39, type: deviceOnline, notifications: 0
2024-06-06 17:27:39  INFO: [T7bb3a04e] id: GA03K1338, time: 2024-06-06 13:17:19, lat: 15.59793, lon: 73.77227, course: 0.0
2024-06-06 17:27:39  INFO: [T7bb3a04e: osmand > 103.56.40.177] 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2024-06-06 17:28:37  INFO: [Tbd4b3d38] disconnected
2024-06-06 17:28:39  INFO: [T7bb3a04e] disconnected
2024-06-06 17:28:40  INFO: [T511617a7] connected
2024-06-06 17:28:40  INFO: [T511617a7: osmand < 103.56.40.177] 474554202f3f64657669636569643d4741303357313739342673706565643d30266c61743d31352e353937383638266c6f6e3d37332e3737323130322674696d657374616d703d3137313736383231363520485454502f312e310d0a486f73743a20676f617772642e746563686e6f747269782e636f2e696e3a353035350d0a436f6e6e656374696f6e3a20636c6f73650d0a0d0a

**2024-06-06 17:28:40**  INFO: Event id: GA03W1794, time: 2024-06-06 17:28:40, type: deviceOnline, notifications: 0
2024-06-06 17:28:40  INFO: [T511617a7] id: GA03W1794, time: 2024-06-06 13:56:05, lat: 15.59787, lon: 73.77210, course: 0.0
2024-06-06 17:28:40  INFO: [T511617a7: osmand > 103.56.40.177] 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2024-06-06 17:29:40  INFO: [T511617a7] disconnected
2024-06-06 17:29:40  INFO: [T1849a7df] connected
2024-06-06 17:29:40  INFO: [T1849a7df: osmand < 103.56.40.177] 474554202f3f64657669636569643d4741303256373531342673706565643d30266c61743d31352e333932343131266c6f6e3d37332e38303839362674696d657374616d703d3136383933353633343920485454502f312e310d0a486f73743a20676f617772642e746563686e6f747269782e636f2e696e3a353035350d0a436f6e6e656374696f6e3a20636c6f73650d0a0d0a

**2024-06-06 17:29:40**  INFO: Event id: GA02V7514, time: 2024-06-06 17:29:40, type: deviceOnline, notifications: 0
2024-06-06 17:29:40  INFO: [T1849a7df] id: GA02V7514, time: 2023-07-14 17:39:09, lat: 15.39241, lon: 73.80896, course: 0.0
2024-06-06 17:29:40  INFO: [T1849a7df: osmand > 103.56.40.177] 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2024-06-06 17:30:33  INFO: [T8b4d1052] connected
2024-06-06 17:30:33  INFO: [T8b4d1052: t55 < 45.128.232.171] 4a4457502d48616e647368616b65
2024-06-06 17:30:38  INFO: [T8b4d1052] disconnected
2024-06-06 17:30:41  INFO: [T1849a7df] disconnected
2024-06-06 17:30:41  INFO: [T6a04da9a] connected
2024-06-06 17:30:41  INFO: [T6a04da9a: osmand < 103.56.40.177] 474554202f3f64657669636569643d4741303746393033342673706565643d30266c61743d31352e353030313337266c6f6e3d37332e3931343133382674696d657374616d703d3136393137343432383320485454502f312e310d0a486f73743a20676f617772642e746563686e6f747269782e636f2e696e3a353035350d0a436f6e6e656374696f6e3a20636c6f73650d0a0d0a

**2024-06-06 17:30:41**  INFO: Event id: GA07F9034, time: 2024-06-06 17:30:41, type: deviceOnline, notifications: 0
Anton Tananaev3 months ago

Don't know where you see a minute, but I see immediate response.

Alan Lobo3 months ago

see the difference between the
osmand > 103... and disconnected. its a minute

Anton Tananaev3 months ago

Connection is controlled by the client - you in this case. If you hold the connection open for a minute after receiving the response, that's on you.

Alan Lobo3 months ago

my client is 1 line of code (in a loop)
file_get_contents($this->base_url . http_build_query($datum))
i.e. essentially a curl command

jinzo3 months ago

If this is PHPs file_get_contents then default_socket_timeout is 60seconds. See: https://www.php.net/filesystem.configuration#ini.default-socket-timeout

So this is completely normal behaviour.

Alan Lobo3 months ago

So, I overcame the issue by specifying a timeout with the request.

I was expecting the server to close the connection after saving the data sent to the url (kind of like apache). it appears the traccar server keeps the connection open and waits for it to timeout

Anton Tananaev3 months ago

I think the main problem is that you're waiting for some content when there's none.

Alan Lobo3 months ago

you are correct. usually I get either some content or some HTTP response code. so I was expecting that.

Anton Tananaev3 months ago

I think you're misreading my comment. There's obviously a response, but there's no content in that response.