Unable to forward data properly

Shrey2 years ago

My config:

  <entry key="event.enable">true</entry>
  <entry key="event.forward.enable">true</entry>
  <entry key="event.forward.url">https://my-server</entry>
  <entry key="event.forward.header">Authorization: Bearer Token</entry>
  <entry key='event.motionHandler'>true</entry>
  <entry key='event.geofenceHandler'>true</entry>
  <entry key='event.alertHandler'>true</entry>
  <entry key='event.ignitionHandler'>true</entry>
  <entry key='event.statusHandler'>true</entry>
  <entry key='event.maintenanceHandler'>true</entry>
  <entry key='forward.enable'>true</entry>
  <entry key='forward.type'>json</entry>
  <entry key='forward.url'>https://my-server</entry>

These are the console logs:

Dec 06 11:04:59 2022-12-06 05:34:59 INFO: [Ta6bd229e] connected
Dec 06 11:04:59 2022-12-06 05:34:59 INFO: [Ta6bd229e: osmand < device-ip] 504f5354202f3f69643d3237363438312674696d657374616d703d31363730333034383937266c61743d32382e39383339383031266c6f6e3d37372e373235303330382673706565643d302e302662656172696e673d302e3026616c7469747564653d3137332e33393939393338393634383433382661636375726163793d31312e36323330303031343439353834393626626174743d37352e3020485454502f312e310d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2044616c76696b2f322e312e3020284c696e75783b20553b20416e64726f69642031323b20323130373131335349204275696c642f534b51312e3231313030362e303031290d0a486f73743a20747261636361722e6170706c2d696e7472612e6469676974616c3a353035350d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a4163636570742d456e636f64696e673a20677a69700d0a436f6e74656e742d4c656e6774683a20300d0a0d0a
Dec 06 11:04:59 2022-12-06 05:34:59 INFO: [Ta6bd229e: osmand > device-ip] 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
Dec 06 11:04:59 2022-12-06 05:34:59 DEBUG: Selected ExecutorServiceProvider implementation [org.glassfish.jersey.client.DefaultClientAsyncExecutorProvider] to be used for injection of executor qualified by [org.glassfish.jersey.client.ClientAsyncExecutor] annotation.
Dec 06 11:04:59 2022-12-06 05:34:59 DEBUG: Selected ScheduledExecutorServiceProvider implementation [org.glassfish.jersey.client.DefaultClientBackgroundSchedulerProvider] to be used for injection of scheduler qualified by [org.glassfish.jersey.client.ClientBackgroundScheduler] annotation.
Dec 06 11:04:59 2022-12-06 05:34:59 DEBUG: Restricted headers are not enabled using [sun.net.http.allowRestrictedHeaders] system property (setting only takes effect on connections created after the property has been set/changed).
Dec 06 11:04:59 2022-12-06 05:34:59 DEBUG: Zero or negative asynchronous thread pool size specified in the client configuration property: [0] Using default cached thread pool.
Dec 06 11:04:59 2022-12-06 05:34:59 INFO: [Ta6bd229e] id: device-identifier, time: 2022-12-06 05:34:57, lat: latitude, lon: longitude, course: 0.0, accuracy: 11.6
Dec 06 11:05:00 2022-12-06 05:35:00 WARN: Position forwarding failed: 0 pending -
Dec 06 11:05:00 java.lang.RuntimeException: HTTP code 403
Dec 06 11:05:00 at org.traccar.forward.PositionForwarderJson$1.completed(PositionForwarderJson.java:72)
Dec 06 11:05:00 at org.traccar.forward.PositionForwarderJson$1.completed(PositionForwarderJson.java:65)
Dec 06 11:05:00 at org.glassfish.jersey.client.JerseyInvocation$1.completed(JerseyInvocation.java:857)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:229)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime.access$200(ClientRuntime.java:62)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime$2.lambda$response$0(ClientRuntime.java:173)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
Dec 06 11:05:00 at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:288)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime$2.response(ClientRuntime.java:173)
Dec 06 11:05:00 at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:278)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime.lambda$null$6(ClientRuntime.java:182)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
Dec 06 11:05:00 at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
Dec 06 11:05:00 at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:288)
Dec 06 11:05:00 at org.glassfish.jersey.client.ClientRuntime.lambda$createRunnableForAsyncProcessing$7(ClientRuntime.java:156)
Dec 06 11:05:00 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
Dec 06 11:05:00 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
Dec 06 11:05:00 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
Dec 06 11:05:00 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
Dec 06 11:05:00 at java.base/java.lang.Thread.run(Thread.java:833)
Dec 06 11:05:00

This is the request body received at my server:

{
  "event": {
    "id": 11,
    "attributes": {},
    "deviceId": 1,
    "type": "deviceOnline",
    "eventTime": "2022-12-06T05:34:59.603+00:00",
    "positionId": 0,
    "geofenceId": 0,
    "maintenanceId": 0
  },
  "device": {
    "id": 1,
    "attributes": {},
    "groupId": 1,
    "name": "***",
    "uniqueId": "******",
    "status": "online",
    "lastUpdate": "2022-12-06T05:34:59.603+00:00",
    "positionId": 42,
    "geofenceIds": null,
    "phone": null,
    "model": null,
    "contact": null,
    "category": null,
    "disabled": false,
    "expirationTime": null
  }
}
Anton Tananaev2 years ago

Is there some problem with the data? Why are you returning an error code?

Shrey2 years ago

@Anton not sure which 'data' you are referring to?
The above included info is all the config that i can see on my end.

I'm using a self-hosted (Cloudron) Traccar server and the Traccar Android app as the client.

Note: my server's receiving url does expect an Authorization header. Could that also be an issue?

Anton Tananaev2 years ago

You're not sending any Authorization header, so it would definitely be a problem if it's expected.

Shrey2 years ago

It works now, after adding:

<entry key="forward.header">Authorization: Bearer Token</entry>

Didn't add this earlier as didn't see it mentioned anywhere in the docs.