Forward events to PHP application

f1cscari3 years ago

So i try change the Server start from using windows charset to UTF-8 - easy? Hell no....

6 Years ago - https://www.traccar.org/forums/topic/mysql-error-change/page/2/#post-1614
It seems, i am going trough every Problem Traccar had to get somehow notification working.
Today, there's no wrapper.conf to change the charset. Building one, adding the suggested line, does change nothing.

2 Years ago - https://www.traccar.org/forums/topic/groups-and-names-in-bulgarian/#post-44063
Today, theres no "characterEncoding=UTF-8" nor a "characterEncoding=cp1251" in the traccar.xml neither in the default.xml Settings.
https://www.traccar.org/configuration-file/ <- nope
Where is it and how to change it? -> https://www.traccar.org/mysql/

<entry key='database.url'>jdbc:mysql://[HOST]:3306/[DATABASE]?serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
Anton Tananaev3 years ago

I think you are going in the wrong direction. The problem has nothing to do with encoding/charset. The problem is likely with the type. It should probably be JSON, not text.

f1cscari3 years ago

See last two posts - https://github.com/neo7530/traccar_pusher/issues/1
There is a Mountain, a Hill and a Priest.... :)

f1cscari3 years ago
<entry key='event.forward.url'>http://my.traccar.page:8082/push/index.php</entry>
2021-10-25 21:00:23  WARN: Event forwarding failed - MessageBodyReader not found for media type=application/octet-stream, type=class java.lang.Object, genericType=class java.lang.Object. - MessageBodyProviderNotFoundException (...)
<entry key='event.forward.url'>http://my.traccar.page:8082/push/</entry>
2021-10-25 21:02:33  WARN: Event forwarding failed - MessageBodyReader not found for media type=text/html;charset=utf-8, type=class java.lang.Object, genericType=class java.lang.Object. - MessageBodyProviderNotFoundException (...)

I can write anything in the index.php, it gives the same warnings. the only difference is...
pointing direct to the index.php - application/octet-stream,
let the server get the index.php - media type=text/html;charset=utf-8

absolute no matter which content, even if the file is empty. strange... isn't it? Something seems broken here?

<entry key='event.forward.url'>http://gotifyhost:port/message?token=GotifyAppToken</entry>
2021-10-25 21:25:47  WARN: Event forwarding failed - HTTP 400 Bad Request - BadRequestException (...)

Gotify gets something, two times:  POST  "/message?token=[masked]"

My hope is now, they do something...

f1cscari3 years ago

It took me 60 hours to find out how this works, with help from the gotify team, i have a working solution for you if you need such.

Install Python - https://www.python.org/downloads/release/python-3100/
run in CMD:

  1. "py -m pip install requests"
  2. "py -m pip install --upgrade pip"

run the Server with "py proxy.py" - after Python Code is done and customized with your ports and GotifyAppToken

Traccar Config:

<entry key='event.forward.enable'>true</entry>
<entry key='event.forward.url'>http://localhost:8083/</entry>
<entry key='event.forward.header'>Content-Type: application/json; charset=UTF-8</entry>

Python Code see: https://github.com/f1cscari/gotify-for-traccar/blob/main/.gitignore/.gitignore