Issue receiving SMS with Kannel - Using USB Modem

Hi, I configured Kannel with my USB Modem and sending SMS is successful. But incoming SMS isn’t working.

I tried some different configurations and haven’t found one that works yet for receiving SMS. Here’s my Kannel config:

# CORE
group = core
admin-port = 13000
admin-password = xxxx
status-password = xxxx
log-file = /var/log/kannel/kannel.log
log-level = 0
access-log = /var/log/kannel/access.log
smsbox-port = 13001
store-type = spool
store-location = /var/spool/kannel/store
smsbox-max-pending = 100


# SMSBOX
group = smsbox
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox.log
log-level = 0
access-log = /var/log/kannel/access.log
mo-recode = true

## SMSC gsm1
group = smsc
smsc = at
smsc-id = gsm1
allowed-smsc-id = gsm1
preferred-smsc-id = gsm1
my-number = +642110xxxxx
#allowed-prefix = "+64;64;0"
unified-prefix = "+64,64,0;+,00"
modemtype = generic
device = /dev/ttyUSB0
speed = 115200
validityperiod = 143
sim-buffering = true
max-error-count = 5
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

## SMSC gsm2
group = smsc
smsc = at
smsc-id = gsm2
allowed-smsc-id = gsm2
preferred-smsc-id = gsm2
my-number = +6420403xxxxx
#allowed-prefix = "+64;64;0"
unified-prefix = "+64,64,0;+,00"
modemtype = generic
device = /dev/ttyUSB6
speed = 115200
validityperiod = 143
sim-buffering = true
max-error-count = 5
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200
init-string = "AT+CNMI=2,2,0,1,0;+CMEE=1"
#reset-string = "AT+CFUN=1"

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200
init-string = "AT+CNMI=2,2,0,1,0;+CMEE=1"
#reset-string = "AT+CFUN=1"

# SENDSMS-USER
group = sendsms-user
default-smsc = none
username = admin
password = pwd
max-messages = 6
concatenation = true

# SMS SERVICE
group = sms-service
keyword = default
omit-empty = true
max-messages = 0
get-url = "https://example.com/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i"

Hi, have you watch kannel log and playsms.log during receiving sms tests ?

tail - f logfilehere

Anton

Hi Anton, Playsms log nothing happens when new SMS comes in… And kannel.log shows this, nothing that indicates a new SMS:

2024-10-17 21:52:11 [1258] [8] DEBUG: Thread 8 (gw/bb_smscconn.c:sms_router) maps to pid 1258.
2024-10-17 21:52:13 [1258] [0] INFO: Loaded 0 messages from store.
2024-10-17 21:52:13 [1258] [0] INFO: MAIN: Start-up done, entering mainloop
2024-10-17 21:52:13 [1258] [0] DEBUG: AT2[gsm1]: start called
2024-10-17 21:52:13 [1258] [0] DEBUG: AT2[gsm2]: start called
2024-10-17 21:53:13 [1258] [5] INFO: Client connected from <127.0.0.1>
2024-10-17 21:53:13 [1258] [5] DEBUG: Started thread 9 (gw/bb_boxc.c:function)
2024-10-17 21:53:13 [1258] [9] DEBUG: Thread 9 (gw/bb_boxc.c:function) maps to pid 1258.
2024-10-17 21:53:13 [1258] [9] DEBUG: Started thread 10 (gw/bb_boxc.c:boxc_sender)
2024-10-17 21:53:13 [1258] [10] DEBUG: Thread 10 (gw/bb_boxc.c:boxc_sender) maps to pid 1258.

Should be something in /var/log/kannel/smsc-gsm1.log or gsm2 depends on which device used

Anton

gsm1 and gsm2 are using same log file. I pasted it here can’t see anything when I test incoming SMS:

2024-10-18 09:50:31 [1291] [6] DEBUG: AT2[gsm1]: → AT+CPMS?^M
2024-10-18 09:50:31 [1291] [7] DEBUG: AT2[gsm2]: ← OK
2024-10-18 09:50:31 [1291] [7] INFO: AT2[gsm2]: AT SMSC successfully opened.
2024-10-18 09:50:31 [1291] [7] DEBUG: AT2[gsm2]: ← +CPMS: 0,10,1,255,1,255
2024-10-18 09:50:31 [1291] [7] DEBUG: AT2[gsm2]: ← OK
2024-10-18 09:50:31 [1291] [7] DEBUG: AT2[gsm2]: → AT+CPMS?^M
2024-10-18 09:50:32 [1291] [6] DEBUG: AT2[gsm1]: ← +CPMS: “SM”,0,10,“ME”,1,255,“ME”,1,255
2024-10-18 09:50:32 [1291] [6] DEBUG: AT2[gsm1]: ← OK
2024-10-18 09:50:32 [1291] [7] DEBUG: AT2[gsm2]: ← +CPMS: “SM”,0,10,“ME”,1,255,“ME”,1,255
2024-10-18 09:50:32 [1291] [7] DEBUG: AT2[gsm2]: ← OK
2024-10-18 09:51:34 [1291] [7] DEBUG: AT2[gsm2]: → AT+CPMS?^M
2024-10-18 09:51:34 [1291] [6] DEBUG: AT2[gsm1]: → AT+CPMS?^M
2024-10-18 09:51:34 [1291] [7] DEBUG: AT2[gsm2]: ← +CPMS: “SM”,0,10,“ME”,1,255,“ME”,1,255
2024-10-18 09:51:34 [1291] [7] DEBUG: AT2[gsm2]: ← OK
2024-10-18 09:51:34 [1291] [6] DEBUG: AT2[gsm1]: ← +CPMS: “SM”,0,10,“ME”,1,255,“ME”,1,255
2024-10-18 09:51:34 [1291] [6] DEBUG: AT2[gsm1]: ← OK

Try again and watch smsbox log, it should be something written in 1 of those Kannel log, then you’ll know why its not showing in playSMS

anton

I checked smsbox.log and can’t find anything in there either. Maybe its kannel config issue? This was smsbox log as follows:
2024-10-18 16:09:10 [4696] [0] DEBUG: Started thread 8 (gw/heartbeat.c:heartbeat_thread)
2024-10-18 16:09:10 [4696] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller) maps to pid 4696.
2024-10-18 16:09:10 [4696] [2] DEBUG: Thread 2 (gwlib/http.c:server_thread) maps to pid 4696.
2024-10-18 16:09:10 [4696] [2] DEBUG: HTTP: Including port 13131, fd 10 for polling in server thread
2024-10-18 16:09:10 [4696] [6] DEBUG: Thread 6 (gw/smsbox.c:url_result_thread) maps to pid 4696.
2024-10-18 16:09:10 [4696] [7] DEBUG: Thread 7 (gw/smsbox.c:http_queue_thread) maps to pid 4696.
2024-10-18 16:09:10 [4696] [8] DEBUG: Thread 8 (gw/heartbeat.c:heartbeat_thread) maps to pid 4696.
2024-10-18 16:09:10 [4696] [3] DEBUG: Thread 3 (gw/smsbox.c:sendsms_thread) maps to pid 4696.
2024-10-18 16:09:10 [4696] [4] DEBUG: Thread 4 (gwlib/gw-timer.c:watch_timers) maps to pid 4696.
2024-10-18 16:09:10 [4696] [5] DEBUG: Thread 5 (gw/smsbox.c:obey_request_thread) maps to pid 4696.

This should be from a working Kannel:

Except smpp parts it seems your config is about the same.

So I dont know why your message not coming to Kannel, have you check your sim card in a real phone and see if you can receive SMS on it.

anton

I tested my USB Modem in a windows app for sending and receiving SMS and it was working:
Screenshot 2024-10-19 095600

Maybe it’s a issue with init-string? I heard people trying different init-strings worked for them.

Ok, try again, this time with:

message-storage = "SM"

(your settings sets to ME)

See in group = modems block

Also you have 2 entries with the same id in group modems, give the other another id, like generic2 perhaps, or remove the block

I tested out setting message storage to SM and didn’t see any difference.

Also I tried removing one of the modem groups and it led to some issues with Kannel. Changing id in group modems also led to this error: 400 Answer: <Sender missing and no global set, rejected>

What is your modem brand and type ?

Share the link, maybe it has some settings need to be set in init

Also re-share your final kannel conf (the one with SM)

I found the model which is “Quectel EC25-AU 4G LTE” It’s a 8 ports modem.

It says on the page to install the drivers, I have them on windows but not on the virtualbox. Heres the modem page: This product is no longer available.

And heres the final kannel config:

CORE

group = core
admin-port = 13000
admin-password = xxx
status-password = xxx
log-file = /var/log/kannel/kannel.log
log-level = 2
access-log = /var/log/kannel/access.log
smsbox-port = 13001
store-type = spool
store-location = /var/spool/kannel/store
smsbox-max-pending = 100
dlr-storage = internal

SMSBOX

group = smsbox
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox.log
log-level = 0
access-log = /var/log/kannel/access.log
mo-recode = true

SMSC gsm1

group = smsc
smsc = at
smsc-id = gsm1
allowed-smsc-id = gsm1
preferred-smsc-id = gsm1
my-number = +64211xxxx
#allowed-prefix = “+64;64;0”
unified-prefix = “+64,64,0;+,00”
modemtype = generic
device = /dev/ttyUSB0
speed = 115200
validityperiod = 143
sim-buffering = true
max-error-count = 5
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = SM
need-sleep = true
sendline-sleep = 200
init-string = “AT+CNMI=2,2,0,1,0;+CMEE=1”
#reset-string = “AT+CFUN=1”

SMSC gsm2

group = smsc
smsc = at
smsc-id = gsm2
allowed-smsc-id = gsm2
preferred-smsc-id = gsm2
my-number = +6420xxxxxx
#allowed-prefix = “+64;64;0”
unified-prefix = “+64,64,0;+,00”
modemtype = generic
device = /dev/ttyUSB6
speed = 115200
validityperiod = 143
sim-buffering = true
max-error-count = 5
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = SM
need-sleep = true
sendline-sleep = 200
init-string = “AT+CNMI=2,2,0,1,0;+CMEE=1”
#reset-string = “AT+CFUN=1”

SENDSMS-USER

group = sendsms-user
default-smsc = none
username = admin
password = xxx
max-messages = 6
concatenation = true

SMS SERVICE

group = sms-service
keyword = default
omit-empty = true
max-messages = 0
get-url = “https://api.expresstxtapp.com/plugin/gateway/kannel/geturl.php?t=%t&q=%q&a=%aQ=%Q&msc=%i

Ok, I have no idea, and I never work with that modem. Maybe you can try first with gsm modem that known to work normally with Kannel, like those wavecom 1 port gsm modem ?

anton

  1. add catch-all= true
  2. Please check yr get-url which is different and seems inaccessable (are you using ngrok?)
  3. e.g for the get-url that i have used
    get-url = “http://x.x.x.x/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i

Hi, I tried a few different configurations and I ended up getting a couple messages to come through. I added the catch-all parameter and tried localhost and using my main url. I’m using ngrok so sometimes it won’t be accessible.

The one change that ended up getting me some messages was when I changed message-storage from message-storage = SM to message-storage = ME. For some reason it will get some messages but not receive any new messages.

Heres the kannel config I ended up with:

CORE

group = core
admin-port = 13000
admin-password = xxx
status-password = xxx
log-file = /var/log/kannel/kannel.log
log-level = 0
access-log = /var/log/kannel/access.log
smsbox-port = 13001
store-type = file
store-file = /var/log/kannel/kannel.store
dlr-storage = internal

SMSBOX

group = smsbox
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox.log
log-level = 0
access-log = /var/log/kannel/access.log
mo-recode = true

SMSC gsm1

group = smsc
smsc = at
smsc-id = gsm1
allowed-smsc-id = gsm1
preferred-smsc-id = gsm1
my-number = +xxx
unified-prefix = “+64,64,0;+,00”
modemtype = generic
device = /dev/ttyUSB0
speed = 115200
validityperiod = 143
sim-buffering = true
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200

SMSC gsm2

group = smsc
smsc = at
smsc-id = gsm2
allowed-smsc-id = gsm2
preferred-smsc-id = gsm2
my-number = +xxx
unified-prefix = “+64,64,0;+,00”
modemtype = generic
device = /dev/ttyUSB6
speed = 115200
validityperiod = 143
sim-buffering = true
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200

SENDSMS-USER

group = sendsms-user
default-smsc = none
username = admin
password = xxxxxx
max-messages = 6
concatenation = true

SMS SERVICE

group = sms-service
keyword = default
catch-all = true
omit-empty = true
max-messages = 0
get-url = “https://api.expresstxtapp.com/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i”

After lots of testing and configurations I got a working config that can send and receive SMS with no problem. If anyone wants here is config:

# CORE
group = core
admin-port = 13000
admin-password = xxx
status-password = xxx
log-file = /var/log/kannel/kannel.log
log-level = 0
access-log = /var/log/kannel/access.log
smsbox-port = 13001
store-type = file
store-file = /var/log/kannel/kannel.store
dlr-storage = internal

# SMSBOX
group = smsbox
bearerbox-host = localhost
bearerbox-port = 13001
sendsms-port = 13131
sendsms-chars = "0123456789+ "
log-file = /var/log/kannel/smsbox.log
log-level = 0
access-log = /var/log/kannel/access.log
mo-recode = true

## SMSC gsm1
group = smsc
smsc = at
smsc-id = gsm1
allowed-smsc-id = gsm1
preferred-smsc-id = gsm1
my-number = +xxx
unified-prefix = "+64,64,0;+,00"
modemtype = generic
device = /dev/ttyUSB0
speed = 115200
validityperiod = 143
sim-buffering = true
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200
init-string = "AT+CNMI=2,1,2,2,0;+CPMS=\"ME\",\"ME\",\"ME\""

## SMSC gsm2
group = smsc
smsc = at
smsc-id = gsm2
allowed-smsc-id = gsm2
preferred-smsc-id = gsm2
my-number = +xxx
unified-prefix = "+64,64,0;+,00"
modemtype = generic
device = /dev/ttyUSB6
speed = 115200
validityperiod = 143
sim-buffering = true
log-file = /var/log/kannel/smsc-gsm1.log
log-level = 0

group = modems
id = generic
message-storage = ME
need-sleep = true
sendline-sleep = 200
init-string = "AT+CNMI=2,1,2,2,0;+CPMS=\"ME\",\"ME\",\"ME\""

# SENDSMS-USER
group = sendsms-user
default-smsc = none
username = admin
password = xxx
max-messages = 6
concatenation = true

# SMS SERVICE
group = sms-service
keyword = default
catch-all = true
omit-empty = true
max-messages = 0
get-url = https://api.expresstxtapp.com/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q&smsc=%i
1 Like