Error notifications SMS

smsoousa3 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 Tananaev3 months ago

Your API returned an error.

smsoousa3 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 Tananaev3 months ago

No, that's not what the error indicates.

Cristian3 months ago

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

lee20 days ago

I appear to still get this error on 6.5 running 6.3 it works without the error. No changes to the traccar.xml

Anton Tananaev20 days ago

Not sure what you mean by "still". This topic is about version 6.5.

lee20 days ago

I am running 6.5 and sending an SMS still results in the error the OP mentioned.
Taking the same xml over to a 6.3 base code results in the SMS notification working.

If I am readin g Cristians post above there was a change reverted in 6.5
https://www.traccar.org/forums/topic/error-notifications-sms/#post-104121

Hopefully this clarifies that "still" means that the code revert does not appear to have resolved this issue..

Anton Tananaev20 days ago

I think you misread the comment. He said he took version 6.5 and reverted some changes.

lee20 days ago

OK, so to be clear, we can expect this to be resolved in a future release?

Anton Tananaev20 days ago

Yes, it will be resolved in the next release. Or you can simply update templates.

lee20 days ago

thanks Anton,
my xml contains only

    <entry key='sms.http.template'>
        {
            "message": "{message}",
            "phoneNumbers": ["{phone}"]
        }
   </entry>

is this the template you're referring to or somewhere esle?
I assumed i was unable to make the change as per Cristians note without needing to recompile ?

Anton Tananaev20 days ago