Forward URL per device

Cristian 9 months ago

One query, to use the forwarding URL per device the following key must be present in the XML file:

<entry key='forward.enable'>true</entry>
Anton Tananaev 9 months ago

Where did you get this information from?

Cristian 9 months ago

I have reviewed several old threads.
What I am trying to do is to use the following option.

but without success
Captura de pantalla 2025-03-19 a la(s) 12.35.18 a.m..png

Anton Tananaev 9 months ago

You have to set a URL in the configuration file, if I remember correctly.

SwayDev 9 months ago

I believe currently per device forward is only supported for JSON type.

traccar.xml Configuration

<entry key='forward.type'>json</entry>  
<entry key='forward.retry.enable'>true</entry>  
<entry key='forward.url'>https://webhook.example.com/position</entry>  

In the traccar.xml set forward.url blank if you don't want all device data to be forwarded.

Device Configuration

Screenshot 2025-03-20 203449.png

GenevieveKingsbury 9 months ago

All good now?

Cristian 9 months ago

the tests I performed showed these errors.

using the example, here I had to add port 5055 otherwise it did nothing.

<entry key='forward.url'>https://webhook.example.com/position</entry>

logs:

2025-03-24 11:04:00  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:01  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:02  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:03  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:07  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:09  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:14  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:21  WARN: Position forwarding failed: 1 pending - No route to host - NoRouteToHostException (...)
2025-03-24 11:04:30  INFO: [T5187cbc8] disconnected
2025-03-24 11:04:33  WARN: An exception was thrown by TimerTask. - Cannot invoke "org.traccar.model.Device.getAttributes()" because "device" is null - NullPointerException (AttributeUtil:52 < *:46 < PositionForwarderJson:49 < PositionForwardingHandler:81 < *:115 < ...)
SwayDev 9 months ago

What version of Traccar are you using?
The URL you have configured are they valid and working?

Anton Tananaev 9 months ago

No route to host

This means your URL is unreachable.

Cristian 9 months ago

I am working with Traccar 6.6

if I do the following, the Traccar demo server receives the information

http://demo.traccar.org:5055/?id=201643&lat=-33.01951&lon=27.90384&altitude=57&speed=36.198704103671705&blocked=false

Captura de pantalla 2025-03-24 a la(s) 12.00.39 p.m..png

configuration in the XML file

    <entry key='forward.type'>json</entry>
    <entry key='forward.retry.enable'>true</entry>
    <entry key='forward.url'></entry>

configuration on the device

Captura de pantalla 2025-03-24 a la(s) 12.21.23 p.m..png

error in log

2025-03-24 12:35:51  INFO: [T98582122] id: 201643, time: 2025-03-24 12:35:50, lat: -38.98056, lon: -72.63824, course: 0.0, accuracy: 50.9
2025-03-24 12:35:51  INFO: [T98582122: osmand > 127.0.0.1] HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n
2025-03-24 12:35:51  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:51  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:51  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:52  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:53  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:54  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
2025-03-24 12:35:58  WARN: Position forwarding failed: 1 pending - HTTP code 400 - RuntimeException (PositionForwarderJson:75 < *:68 < ...)
Anton Tananaev 9 months ago

I'm kind of confused. Are you expecting this to work? Port 5055 doesn't accept JSON.

Cristian 9 months ago

Understood Anton, I did not handle that information.

I made the following change

Captura de pantalla 2025-03-24 a la(s) 12.49.55 p.m..png

But nothing happens

2025-03-24 12:50:29  INFO: [T4e9f7811] id: 201643, time: 2025-03-24 12:50:28, lat: -38.98003, lon: -72.63799, course: 0.0, accuracy: 100.0
2025-03-24 12:50:29  INFO: [T4e9f7811: osmand > 127.0.0.1] HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n2025-03-24 12:50:59  INFO: [T4e9f7811] disconnected
Anton Tananaev 9 months ago

That makes even less sense because this URL doesn't exist.

Cristian 9 months ago

Ah ok, then I give up, keep trying, it's like playing guessing games to find the solution, thanks to all of you.

Atulalma 9 months ago

@SwayDev as your say json support per device forward how can I do this can I forward each device to different different endpoint.