event forwarding

baba2 years ago

hi
Please help me....

  • traccar.xml
  <entry key='event.forward.enable'>true</entry>
    <entry key='event.forward.url'>http://localhost:8000/amnir/track/event_forwarding</entry>
    <entry key='event.forward.header'>
        content-type: application/json
        cache-control: no-cache
    </entry>

python code ....

  • views.py
@csrf_exempt
@require_POST
def event_forwarding(request):
    body = request.body.decode('utf-8')
    print(body)
  • urls.py
 path('event_forwarding', views.event_forwarding, name='event_forwarding'),
  • erreur tracker-server
error - Index 1 out of bounds for length 1 - ArrayIndexOutOfBoundsException (EventForwarderJson:46 < NotificationManager:134 < *:119 < *:148 < ConnectionManager:245 < ...)
NanaYaw2 years ago

The error message "Index 1 out of bounds for length 1 - ArrayIndexOutOfBoundsException" suggests that there may be an issue with the format or structure of the JSON data being sent.

First, make sure that the JSON data being sent by Traccar matches the expected format and structure for the endpoint you are using to receive the data. In this case, it looks like you are expecting JSON data with a 'content-type' header of 'application/json'. You may also want to check that the data being sent includes all the required fields.

Second, make sure that the endpoint you are using to receive the JSON data is working correctly. The error message suggests that there may be an issue with the code in your event_forwarding view in views.py. Try logging or printing the request object to see if you are receiving any data from Traccar, and make sure that your view is correctly decoding the JSON data and processing it.

Finally, if you are still encountering issues, you may want to consult the Traccar documentation or reach out to the Traccar support team for assistance. They may be able to provide additional guidance on setting up event forwarding and troubleshooting any issues you encounter.

Anton Tananaev2 years ago

Just remove the event.forward.header config parameter. Those headers don't really make sense.