Forward raw data

orcas 5 years ago

Is it possible to forward websocket data to another server? I am using my device with traccar but I would like to forward all comms between device and traccar with the manufacturer server so I can use traccar and also the manufacturer interface. Is this possible? Thanks

Anton Tananaev 5 years ago

There's forwarding available. Check documentation.

orcas 5 years ago

Yes, I know I can forward decoded data. Is it possible to forward raw data, I.e. the same data we receive?

Anton Tananaev 5 years ago

You can use database.saveOriginal to save raw data as an attribute.

orcas 5 years ago

Yes I have checked that. Also saveempty. I have configured my device to send data to http://myserver:5013, and I would like to forward all data also to http://otherserver:7700. If I configure my device for the later, other server works. Is it possible to do this with traccar?

Gus 3 years ago

I noticed a new commit from 15hrs ago with description "raw data forwarding." Does that mean that functionality has been implemented? If yes, can you share documentation on how to use/test it? Thanks! Traccar is a great project.

Anton Tananaev 3 years ago

Yes, it's implemented. Check the commit for the configuration details.

Peter Dimitrov 3 years ago

Thank you for implementing such functionality, it really is useful, especially when using more than 1 servers for various reasons.
Do you plan on creating such functionality for specific devices only, not server-wide?
Also, do you think it will be possible to receive data to Traccar 1 on one port and then to redirect it to Traccar 2 on second port (different from the first one)?

PS: For the previous post, here is the commit:
https://github.com/traccar/traccar/commit/dd8c46eec3282e344eeea5e27d084448c85e1518

Anton Tananaev 3 years ago

Don't have any active plans, but:

  1. Selecting specific devices to forward might be useful. I think we can implement something like this, but need to decide how it would work.
  2. Changing port number - I'm not so sure about. You can easily reroute ports using other tools, like iptables on Linux.

Feel free to create feature requests. Or if you want to contribute - even better.

Gus 3 years ago

Thank you again, Anton and Peter.

I tried adding the following entry to the configuration file and restarting the traccar service to start raw data forwarding but I'm not receiving any messages on my other server:

<entry key='server.forward'>192.168.0.111</entry>

The servers are on the same IP subnet and can ping each other. What am I missing? Is there any debug log I can enable?

Thanks in advance.

Anton Tananaev 3 years ago

Any errors in the log? Are you sure you're using the latest version?

Gus 3 years ago

Sorry, I missed the following log message: (And yes, I've fully upgraded to 5.7.)

2023-04-27 19:10:29  WARN: Network forwarding error - Broken pipe - SocketException (... < NetworkForwarder:59 < NetworkForwarderHandler:60 < ...)

I think the problem might be on my receiving server. I'll do some more investigation.

Gus 3 years ago

Just to be sure: if on my receiving server I set up a websocket listening on port 5027 (for Teltonika devices), I should receive the raw data, correct?

Anton Tananaev 3 years ago

What WebSocket? It's not HTTP-based in any way.

Gus 3 years ago

Ok. Thanks! I apologize. I thought it was based on http for some reason. If it's a simple TCP connection (I'm using TCP with Teltonika) then I'll have to re-write my receiving server code.

One last question: the code mentions a PROTOCOL_PORT config key. Do I need to also have it in the configuration file? What happens if I don't?