Connecting GPS Watch to Server

Percy6 years ago

Hello,

I have a docker NGINX proxy server with traccar on a /web/ path (not on the root domain)

It works with this configuration:

location /web/ {
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_cookie_path /api /web/api;
    proxy_redirect http://traccar:8082/ /web/;
    proxy_redirect ws://traccar:8082/api/socket /web/api/socket;
    proxy_pass http://traccar:8082/;
    proxy_read_timeout 600s;
}

location / {
   proxy_pass http://traccar:5005;
}

The problem comes when I want to connect the watch to the server. I want to use the root location for this (/), and since the watch uses a TCP protocol, but if I use this (no http):

location / {
   proxy_pass traccar:5005;
}

Then the /web/ path that loads the traccar web UI doesn't load anymore. So it seems that even forcing to use /web/ for the Traccar Web UI, it loads some info from the root path (/)

I'm using this docker container to manage my NGINX setup: https://github.com/jwilder/nginx-proxy

I would appreciate if anyone is using a similar setup to let me know how to configure this properly and also please note I'm using ngrok to test and this is how it is set:

tcp://0.tcp.ngrok.io:[my-port] -> localhost:5005

I see ngrok receiving the data from the gps watch (chinese watch Q50), but I cannot get Traccar to register the data. I checked the Traccar logs but only see the requests from the Traccar Web UI.

Thank you,

Anton Tananaev6 years ago

You can't HTTP-proxy a raw TCP port.

Percy6 years ago

Anton,

Thanks for your response.

I did try removing the HTTP proxy and used this:

location / {
   proxy_pass traccar:5005;
}

But it makes the Web UI not load, and still there is no data registering in Traccar. How would you approach this?

Anton Tananaev6 years ago

What you are doing makes zero sense to me. There is one port for web app and there are other ports (most raw TCP) for devices. Please don't mix those two together. HTTP proxy will ONLY work for HTTP protocols.

Percy6 years ago

I'm trying to keep them separate. But don't know how to proceed from here.

I want to listen to raw TCP requests and proxy those to traccar:5005, and the web UI is proxy to traccar:8082 under the /web/ path. This is my end goal - but looking on how to proceed from here.

Results so far are: /web/ works (conflicting with the root / location rule), but it is not getting the TCP request in any case. On the other case taking the HTTP out of the root location, then nothing works.

Anton Tananaev6 years ago

You can't use HTTP proxy for non-HTTP protocol. It's just impossible.

Percy6 years ago

I know already - but looking for a proper configuration suggestion to make both work (TCP raw request proxy to the right location, same for the Web UI) and not mix them.

Anton Tananaev6 years ago

You can proxy web app through nginx, but for TCP ports you need to use regular port forwarding. You can't use HTTP proxy for TCP port. You can't proxy them.

Percy6 years ago

I followed your advice and now it is receiving this data (on the log file):

[3G*6109395381*0009*LK,0,0,92]

I added the device on the web UI, but it is not recognized. I used the ID on the back of the watch and then tried the IMEI, but still says "offline"

Anton Tananaev6 years ago

Follow troubleshooting guide.

Percy6 years ago

Anton,

Followed your troubleshooting guide and tested all ports (https://www.traccar.org/clones/) including the last one 5093 which gave an error. I also looked on the test integration file (https://raw.githubusercontent.com/tananaev/traccar/master/tools/test-integration.py) and it it definitely a "watch" protocol.

I also found an open issue (https://github.com/traccar/traccar/issues/1864) that you explicitly say port 5093 - and suddenly when I use that port, I get this error:

2018-04-06 17:22:20 DEBUG: [86A5B0E6: 5093 > 172.24.0.1] HEX: 5b33472a363130393339353338312a303030322a4c4b5d
2018-04-06 17:22:20  WARN: [86A5B0E6] error - scheme - NullPointerException (... < EventForwarder:52 < NotificationManager:105 < *:111 < ConnectionManager:109 < ...)

I was using Traccar 3.15, and I upgraded to 3.16 - but I still get the same error: NullPointerException.

I suppose there is a problem with the internal protocol used on Traccar for this "watch" protocol.

Let me know if you need more info to pinpoint the cause of the problem.

Percy6 years ago

Anton, I opened an issue for this:

https://github.com/traccar/traccar/issues/3836

Anton Tananaev6 years ago

Please never duplicate messages. Your error is caused by incorrect event forwarding configuration. It has nothing to do with watch protocol and it's not a server bug.

Percy6 years ago

Sorry Anton... I thought Forums and Github issues were different things to you. Now I know.

Percy6 years ago

It helped. I disabled the event forwarder on the configuration and it worked. Probably a friendlier error message would have helped pinpoint this issue faster. Anyways I sent you a protocol document I got very recently.