SMS commands via Twilio - config not working?

Gareth Curtis5 years ago

Hi there,

Trying to send commands via SMS. Little confused over SMS and SMPP. I've got a Twilio account and confirmed it can send messages. I've put the config into Traccar:

<entry key='notificator.types'>web,mail,sms</entry>
<entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
<entry key='sms.http.url'>https://api.twilio.com/2010-04-01/Accounts/{MY_SID}/Messages.json</entry>
<entry key='sms.http.user'>{MY_SID}</entry>
<entry key='sms.http.password'>{MY_PASSWORD}</entry>
<entry key='sms.http.template'>From=%2B441315104795&amp;To={phone}&amp;Body={message}</entry>

Little confused over:

<entry key='sms.enable'>true</entry>

It would seem I should turn it on but then it's not mentioned in your example config for Twilio and this says don't turn it on:

https://www.traccar.org/forums/topic/setting-up-twilio/

Because then it seems to refer to SMPP and not needing that... Must commands only be sent via SMPP and not via SMS/Twilio?

So I tried SMS = false, but if I try to send an SMS command via the web interface, it says:

SMS is not enabled - RuntimeException (BaseProtocol:127 < CommandsManager:66 < CommandResource:71 < ...)

If I go SMS = true, Traccar starts but the log says:

2019-07-16 12:17:07  WARN: Client did not connect. - Connection refused - ConnectException (...)
2019-07-16 12:17:07  WARN: Unable to connect to SMPP server:  - Connection refused - ConnectException (...)

^ What is the above trying to do though? I note that if I try to do a GET on the Twilio URL it says it is not available for test credentials...

Re SMS enable required or not, it says below you must turn SMS on!

https://www.traccar.org/forums/topic/sms-notification/

Any advice please?

Many thanks.

P.S. I saw the post about constraints on the tc_device_notifications table, to confirm; I'm using MariaDB, MySQL driver and InnoDB engine. And I have two foreign keys on that table.

Anton Tananaev5 years ago

At the moment it's not possible to use HTTP SMS API for commands. You would need SMPP for that.

pi0074 years ago

hi Anton, i'm using twilio api for notifications and commands .

my congig:

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
    <entry key='sms.http.url'>https://api.twilio.com/2010-04-01/Accounts/*************************/Messages.json</entry>
    <entry key='sms.http.user'>***********************</entry>
    <entry key='sms.http.password'>***************</entry>
    <entry key='sms.http.template'>
    From=%2B12529999422&amp;To={phone}&amp;Body={message}
    </entry>

it's workin very well for commands but not for notifications...
my logs:

2021-06-24 20:30:49  WARN: SMS send failed - HTTP 400 Bad Request - BadRequestException (...)

pls help me

Anton Tananaev4 years ago

You need to check request and response.

pi0074 years ago

thank you for your answer ,but how ? which request and response? cause i don't see anything on the twilio logs.

pi0074 years ago

and i tried to reach the sms server, it's workin that's why sending sms commands is workin but sms notifications don't.

Anton Tananaev4 years ago

You can try setting up a proxy to capture request or just use Wireshark or something like that.