Traccar OpenGTS protocol ignores the GET method from curl or wget but accept Firefox/Chrome

Lukas Z.6 years ago

Traccar server ignores the same url transmitted by Curl or Wget but it accept this url why you fill it to the browser (Firefox/Chrom). I have no idea how to solve it. I need to transmit the url from bash script. Thanks for help

lukas@lukas-VPCZ21V9E ~ $ curl -v "http://192.168.122.52:5159/?id=999000000000003&gprmc=$""GPRMC,165318.0,A,5008.450529,N,01407.108631,E,0.0,151.7,180918,1.2,E,A*0F"
* Hostname was NOT found in DNS cache
*   Trying 192.168.122.52...
* Connected to 192.168.122.52 (192.168.122.52) port 5159 (#0)
> GET /?id=999000000000003&gprmc=$GPRMC,165318.0,A,5008.450529,N,01407.108631,E,0.0,151.7,180918,1.2,E,A*0F HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.122.52:5159
> Accept: */*
> 
< HTTP/1.1 200 OK
< content-length: 0
< 
* Connection #0 to host 192.168.122.52 left intact
lukas@lukas-VPCZ21V9E ~ $ ^C

From Curl

2018-09-18 16:53:21  INFO: [0529b8ba] connected
2018-09-18 16:53:21 DEBUG: [0529b8ba: 5159 < 192.168.14.102] HEX: 474554202f3f69643d393939303030303030303030303033266770726d633d244750524d432c3136353331382e302c412c353030382e3435303532392c4e2c30313430372e3130383633312c452c302e302c3135312e372c3138303931382c312e322c452c412a304620485454502f312e310d0a557365722d4167656e743a206375726c2f372e33352e300d0a486f73743a203139322e3136382e3132322e35323a353135390d0a4163636570743a202a2f2a0d0a0d0a
2018-09-18 16:53:21 DEBUG: [0529b8ba: 5159 > 192.168.14.102] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a

from browser

2018-09-18 16:54:59 DEBUG: [592936e9: 5159 < 192.168.14.102] HEX: 474554202f66617669636f6e2e69636f20485454502f312e310d0a486f73743a203139322e3136382e3132322e35323a353135390d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204d6f7a696c6c612f352e3020285831313b204c696e7578207838365f363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29205562756e7475204368726f6d69756d2f36352e302e333332352e313831204368726f6d652f36352e302e333332352e313831205361666172692f3533372e33360d0a4163636570743a20696d6167652f776562702c696d6167652f61706e672c696d6167652f2a2c2a2f2a3b713d302e380d0a526566657265723a20687474703a2f2f3139322e3136382e3132322e35323a353135392f3f69643d393939303030303030303030303033266770726d633d244750524d432c3136353331382e302c412c353030382e3435303532392c4e2c30313430372e3130383633312c452c302e302c3135312e372c3138303931382c312e322c452c412a30460d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570742d4c616e67756167653a2063732d435a2c63733b713d302e390d0a0d0a
2018-09-18 16:54:59 DEBUG: [592936e9: 5159 > 192.168.14.102] HEX: 485454502f312e31203430302042616420526571756573740d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-09-18 16:54:59  INFO: [592936e9] id: 999000000000003, time: 2018-09-18 18:53:18, lat: 50.14084, lon: 14.11848, course: 151.7
Anton Tananaev6 years ago

Message from your browser is an icon request:

GET /favicon.ico HTTP/1.1

So, you provided wrong log fragment.

Lukas Z.6 years ago

Sorry, I copied wrong part...

From browser:

2018-09-18 16:54:59  INFO: [592936e9] connected
2018-09-18 16:54:59 DEBUG: [592936e9: 5159 < 192.168.14.102] HEX: 474554202f3f69643d393939303030303030303030303033266770726d633d244750524d432c3136353331382e302c412c353030382e3435303532392c4e2c30313430372e3130383633312c452c302e302c3135312e372c3138303931382c312e322c452c412a304620485454502f312e310d0a486f73743a203139322e3136382e3132322e35323a353135390d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e3020285831313b204c696e7578207838365f363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29205562756e7475204368726f6d69756d2f36352e302e333332352e313831204368726f6d652f36352e302e333332352e313831205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c696d6167652f61706e672c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570742d4c616e67756167653a2063732d435a2c63733b713d302e390d0a0d0a
2018-09-18 16:54:59 DEBUG: [592936e9: 5159 > 192.168.14.102] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-09-18 16:54:59 DEBUG: [592936e9: 5159 < 192.168.14.102] HEX: 474554202f66617669636f6e2e69636f20485454502f312e310d0a486f73743a203139322e3136382e3132322e35323a353135390d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204d6f7a696c6c612f352e3020285831313b204c696e7578207838365f363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29205562756e7475204368726f6d69756d2f36352e302e333332352e313831204368726f6d652f36352e302e333332352e313831205361666172692f3533372e33360d0a4163636570743a20696d6167652f776562702c696d6167652f61706e672c696d6167652f2a2c2a2f2a3b713d302e380d0a526566657265723a20687474703a2f2f3139322e3136382e3132322e35323a353135392f3f69643d393939303030303030303030303033266770726d633d244750524d432c3136353331382e302c412c353030382e3435303532392c4e2c30313430372e3130383633312c452c302e302c3135312e372c3138303931382c312e322c452c412a30460d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570742d4c616e67756167653a2063732d435a2c63733b713d302e390d0a0d0a
2018-09-18 16:54:59 DEBUG: [592936e9: 5159 > 192.168.14.102] HEX: 485454502f312e31203430302042616420526571756573740d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-09-18 16:54:59  INFO: [592936e9] id: 999000000000003, time: 2018-09-18 18:53:18, lat: 50.14084, lon: 14.11848, course: 151.7
2018-09-18 17:01:38  INFO: [592936e9] disconnected
Lukas Z.6 years ago

Only device status is updated to "online" when using curl or wget but there are no coordinates, time, anything

Lukas Z.6 years ago

The only difference I have found is that curl closes session immediately after http response HTTP/1.1 200 OK content-length: 0
but browser stays connected for approx one minute

Anton Tananaev6 years ago

I have tested your curl command and it works fine for me.

Lukas Z.6 years ago

Yes it really works from but only from some computers. There is any problem with timing... The problem is that the curl and wget closes session immediately and traccar doesn't parse coordinates and doesn't write them to the log and to the database. If there is some delay it works. I solved it using telnet. Here is sample part of working and not working bash scripts (the only difference is sleep 1 after http GET)

working

expect << EOFEXPECT
set timeout 2
spawn telnet 192.168.122.52 5159
sleep 1
send "GET $TCURL?id=$TRID&gprmc=\\$TELRESP HTTP/1.1"
send "\r"
send "\r"
sleep 1
send "q\r"
EOFEXPECT

not working

expect << EOFEXPECT
set timeout 2
spawn telnet 192.168.122.52 5159
sleep 1
send "GET $TCURL?id=$TRID&gprmc=\\$TELRESP HTTP/1.1"
send "\r"
send "\r"
send "q\r"
EOFEXPECT
Anton Tananaev6 years ago

You just need to wait for server response. Both curl and wget support it.

Lukas Z.6 years ago

You mean HTTP/1.1 200 OK content-length: 0 ?
I get it

485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a

As I wrote - curl works on one (windows)machine but it doesn't works from other (two different linux) machines.
Also telnet doesn't work if there is no delay after

Lukas Z.6 years ago

The same result with fetch....
If the session is closed too quickly, the coordinates are not calculated. Only status of device is updated.

Lukas Z.6 years ago

IT DOESN'T WORK

2018-10-04 00:10:05  INFO: [1480675a] connected
2018-10-04 00:10:05 DEBUG: [1480675a: 5159 < 176.222.226.26] HEX: 48454144202f3f69643d393939303030303030303030303033266770726d633d244750524d432c3233323235372e3030302c412c353130382e343536332c4e2c30313430372e313130312c452c302e30312c3335322e36322c3033313031382c2c2c412a364420202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020485454502f312e310d0a486f73743a206563322d31382d3139352d3130312d3138322e65752d63656e7472616c2d312e636f6d707574652e616d617a6f6e6177732e636f6d3a353135390d0a557365722d4167656e743a206375726c2f372e34372e300d0a4163636570743a202a2f2a0d0a0d0a
2018-10-04 00:10:05 DEBUG: [1480675a: 5159 > 176.222.226.26] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-10-04 00:10:05  INFO: [1480675a] disconnected

IT WORKS

2018-10-04 00:10:03  INFO: [85d932e5] connected
2018-10-04 00:10:04 DEBUG: [85d932e5: 5159 < 81.91.83.169] HEX: 47455420687474703a2f2f6563322d31382d3139352d3130312d3138322e65752d63656e7472616c2d312e636f6d707574652e616d617a6f6e6177732e636f6d3a3a2f3f69643d393939303030303030303030303234266770726d633d244750524d432c3232303935392e302c412c353030352e3537373730332c4e2c30313431372e3233363634312c452c302e302c3136372e372c3033313031382c312e322c452c412a303920485454502f312e310d0a
2018-10-04 00:10:04 DEBUG: [85d932e5: 5159 < 81.91.83.169] HEX: 0d0a
2018-10-04 00:10:04 DEBUG: [85d932e5: 5159 > 81.91.83.169] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2018-10-04 00:10:04  INFO: Position filtered by Distance filters from device: 999000000000024
2018-10-04 00:10:05  INFO: [85d932e5] disconnected
Anton Tananaev6 years ago

I need a way to reproduce the issue.

Lukas Z.6 years ago

Today I found that it works when geocoder disabled. If geocoder is enabled and I use curl or wget or something it doesn't work.

Traccar v 4.0, running on ubuntu linux, OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)

    <entry key="config.default">./conf/default.xml</entry>
    <entry key='database.driver'>org.h2.Driver</entry>
    <entry key='database.url'>jdbc:h2:tcp://localhost:33433//opt/traccar/data/database</entry>
    <entry key='database.user'>sa</entry>
    <entry key='database.password'></entry>
    <entry key='logger.enable'>true</entry>
    <entry key='logger.level'>debug</entry>
    <entry key='logger.file'>/opt/traccar/logs/tracker-server.log</entry>

    <entry key='filter.enable'>true</entry>
    <entry key='filter.duplicate'>true</entry>
    <entry key='filter.zero'>true</entry>
    <entry key='filter.invalid'>true</entry>
    <entry key='filter.distance'>15</entry>
    <entry key='filter.skipLimit'>1200</entry>

    <entry key='gl200.port'>37493</entry>
    <entry key='opengts.timeout'>120</entry>

    <entry key='geocoder.enable'>true</entry>
    <entry key='geocoder.type'>nominatim</entry>
    <entry key='geocoder.url'>https://locationiq.org/v1/reverse.php</entry>
    <entry key='geocoder.key'>915b7d8181539c</entry>
    <entry key='geocoder.onRequest'>true</entry>
    <entry key='geocoder.processInvalidPositions'>false</entry>
    <entry key='geocoder.reuseDistance'>50</entry>

    <entry key='server.timeout'>120</entry>
    <entry key='status.timeout'>60</entry>
    <entry key='database.historyDays'>365</entry>
Anton Tananaev6 years ago

I have tested (using test-generator.py script from tools) with geocoder enabled and I'm still not able to reproduce the issue.

Lukas Z.6 years ago

It must be related to some timing. I set up the traffic shaper on the wan interface of the Linux machine with curl (Mikrotik router with GPS). Speed limit 8kbps for outgoing traffic. Coordinates are now written to the traccar database successfully on the Traccar server. If I disable the shaper traccar stop save records to the database immediately.
It seems that traccar doesn't save coordinates if the answer from geocoder came later than device is disconnected.
If geocoder is disabled it works with or without shaper correctly.