Issue with Forwarding Data Between Two Traccar Servers - "400 Bad Request" (version 6.2)

ozz_wizard4 months ago

Hello everyone,

I am experiencing an issue with forwarding data between two Traccar servers (version 6.2). I have configured the main server to forward data to the target server using the Osmand protocol. However, the target server is constantly returning "400 Bad Request". Here are the configuration details and logs:
Sender Server Configuration (traccar.xml):

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.10.157:5055</entry>
<entry key='forward.json'>true</entry>

<entry key='event.forward.enable'>true</entry>
<entry key='event.forward.url'>http://192.168.10.157:5055</entry>
<entry key='event.forward.json'>true</entry>

Target Server Configuration (traccar.xml):

<entry key='osmand.protocol.enable'>true</entry>
<entry key='osmand.port'>5055</entry>

Log

2024-07-28 15:41:32  INFO: [T9cedecb1: osmand < 192.168.10.155] 474554202f20485454502f312e310d0a557365722d4167656e743a204a65727365792f332e312e3720284874747055726c436f6e6e656374696f6e2032312e302e32290d0a486f73743a203139322e3136382e31302e3135373a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a0d0a
2024-07-28 15:41:32  INFO: [T9cedecb1: osmand > 192.168.10.155] 485454502f312e31203430302042616420526571756573740d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2024-07-28 15:41:37  INFO: [T9cedecb1] disconnected

Both servers are running Traccar version 6.2.

Does anyone have any idea what might be wrong with my configuration or data format? Any help would be greatly appreciated.

Thank you in advance!

Anton Tananaev4 months ago

Not sure why you're expecting this to work. OsmAnd protocol is not expecting JSON data, so it's obviously failing.

ozz_wizard4 months ago

Hello Anton,

Thank you. You were right; the issue was with sending JSON data. After switching to URL-encoded format, forwarding works perfectly when we manually use cURL. However, when the main server forwards data automatically, it still doesn't work correctly. Do you have any suggestions on what might be causing this?

Sender

curl -X POST "http://192.168.10.157:5055?id=577947&lat=45.0&lon=-93.0×tamp=2023-07-28T14:41:46.000Z&altitude=0&speed=0&course=0&accuracy=0&battery=50"

Target

2024-07-28 16:48:47  INFO: [T1385f305: osmand < 192.168.10.155] 504f5354202f3f69643d353737393437266c61743d34352e30266c6f6e3d2d39332e302674696d657374616d703d323032332d30372d32385431343a34313a34362e3030305a26616c7469747564653d302673706565643d3026636f757273653d302661636375726163793d3026626174746572793d353020485454502f312e310d0a486f73743a203139322e3136382e31302e3135373a353035350d0a557365722d4167656e743a206375726c2f382e372e310d0a4163636570743a202a2f2a0d0a0d0a
2024-07-28 16:48:47  INFO: [T1385f305] id: 577947, time: 2023-07-28 16:41:46, lat: 45.00000, lon: -93.00000, course: 0.0
2024-07-28 16:48:47  INFO: [T1385f305: osmand > 192.168.10.155] 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a

This is the log when the primary Traccar sends:

2024-07-28 16:50:38  INFO: [Tc7b81702] connected
2024-07-28 16:50:38  INFO: [Tc7b81702: osmand < 192.168.10.155] 474554202f20485454502f312e310d0a557365722d4167656e743a204a65727365792f332e312e3720284874747055726c436f6e6e656374696f6e2032312e302e32290d0a486f73743a203139322e3136382e31302e3135373a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a0d0a
2024-07-28 16:50:38  INFO: [Tc7b81702: osmand > 192.168.10.155] 485454502f312e31203430302042616420526571756573740d0a636f6e74656e742d6c656e6774683a20300d0a0d0a

Now is the following configuration
Sender

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.10.157:5055</entry>

<entry key='event.forward.enable'>true</entry>
<entry key='event.forward.url'>http://192.168.10.157:5055</entry>

Recipient

<entry key='osmand.protocol.enable'>true</entry>
<entry key='osmand.port'>5055</entry>

Thanks.

Anton Tananaev4 months ago

Your configuration won't work. Where did you get these parameters from?

ozz_wizard4 months ago

Anton this is one of the many variants that I tried, almost all of them resulted in the server stopping.
After many attempts, I came up with something that does not crash the server.

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.10.157:5055/?id={uniqueId}&amp;lat={latitude}&amp;lon={longitude}&amp;timestamp={deviceTime}&amp;bearing={course}&amp;hdop={accuracy}&amp;altitude={altitude}&amp;speed={speed}&amp;status={status}&amp;accuracy={accuracy}&amp;battery={battery}&amp;ip={ip}&amp;ignition={ignition}&amp;motion={motion}&amp;power={power}&amp;sat={sat}&amp;odometer={odometer}</entry>

Here's how I did it right now the way I understood it should be from reading about it because I was unfamiliar with this part until now. And I persistently make mistakes and go around in circles, or my server crashes or I have errors.

<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://192.168.10.157:5055</entry>

<entry key='event.forward.enable'>true</entry>
<entry key='event.forward.url'>http://192.168.10.157:5055</entry>
<entry key='event.forward.filter'>deviceOnline,deviceOffline,deviceMoving,deviceUnknown,deviceStopped</entry>

My goal is to forward everything I can to another server.

Thank you very much for your patience and willingness to help.

Anton Tananaev4 months ago

It seems like you're just making up configuration parameters without checking with the documentation. I suggest you research documentation before trying anything or asking for help.

Rodney Yeo4 months ago

I was hoping too for such forwarding function of trackers data from TracCar Demo servers to self hosting DDNS home TracCar Raspberry Pi servers.

Resons being all SinoTrack Device Trackers only support IP address format for server registration and not domain name format which all generic trackers supports.