Error notifications SMS

smsoousa2 months ago

Hello everybody! I use SMS notifications to trigger other APIs like WhatsApp for example, in previous versions, 5.9 for example everything worked perfectly. After upgrading to version 6.5, I'm getting this error every time a notification is triggered:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>SyntaxError: Unexpected token <br> in JSON at position 51<br> &nbsp; &nbsp;at JSON.parse (&lt;anonymous&gt;)<br> &nbsp; &nbsp;at parse (/opt/1015/node_modules/body-parser/lib/types/json.js:92:19)<br> &nbsp; &nbsp;at /opt/1015/node_modules/body-parser/lib/read.js:128:18<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/opt/1015/node_modules/raw-body/index.js:238:16)<br> &nbsp; &nbsp;at done (/opt/1015/node_modules/raw-body/index.js:227:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/opt/1015-/node_modules/raw-body/index.js:287:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:517:28)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1400:12)<br> &nbsp; &nbsp;at process.processTicksAndRejections (node:internal/process/task_queues:82:21)</pre> </body> </html> - MessageException (HttpSmsClient:99 < NotificatorSms:48 < Notificator:39 < NotificationResource:107 < ...)

My XML configuration looks like this:

<entry key='notificator.types'>web,sms</entry>
<entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
<entry key='sms.http.url'>http://my-ip:1015/send-message</entry>
<entry key='sms.http.template'>{"number": "{phone}","message": "{message}"}</entry>

Any tips on what might be happening? Remembering that this worked perfectly in previous versions.

Thanks

Anton Tananaev2 months ago

Your API returned an error.

smsoousa2 months ago

Did anything change in the body of the sending message? Json to HTML Example. The error indicates that traccar is returning html data and not json.

Anton Tananaev2 months ago

No, that's not what the error indicates.

Cristian2 months ago

I reverted that change and it worked again in Traccar 6.5
https://github.com/traccar/traccar/commit/c75db08c7991af8b3ccc1341a3a80b2f3a6e53cd