-->
🏠 🔍
SHAREOLITE

How to : Send SMS using Kannel SMS gateway - configuration , start-up , status check and shutdown procedures


In our previous article , a brief overview of Kannel Gateway architecture and its installation process was given. In this section - we will discuss on basic sample configurations which should be sufficient to connect to a mobile operator SMS center for sending and receiving messages.

Below is a sample configuration file in which parameters are extracted from the default kannel.conf provided in kannel gateway.1.4.3 release to support SMS gateway features. Copy the contents highlighted in blue to a text file under /kannel/cfg/. For example /kannel/cfg/sms1.conf ( Refer our previous article on the installation notes)

group = core
# The below two ports are used for kannel gateway administration.
# The port values should be unique when multiple conf files are created.
admin-port = 10000
smsbox-port = 10001
admin-password = shareolite
log-file = "/kannel/log/bearerbox.log"
# Default log level - enables low level logs also
log-level = 0
box-allow-ip = "127.0.0.1"
access-log = "/kannel/test-access.log"

#This is the main group where SMS center details will be configured
group = smsc
smsc = smpp
smsc-id = http
#SMS center TCP port - which mobile operator provides.
port = 4776
#SMS center Host IP - which mobile operator provides
host = 201.45.66.3
# Mode which indicates whether Transmit & Receive is enabled or only Trasmit
transceiver-mode = 1
system-type = kannel
#SMS center account details - username and password shared by mobile operator
smsc-username = shareo
smsc-password = lite
# Type of Number - Alphanumeric , Numeric etc . Refer manual for details
source-addr-ton = 0
source-addr-npi = 0
dest-addr-ton = 0
dest-addr-npi = 0
keepalive = 600

# This is sendsms process configuration . For kannel gateway management.
group=sendsms-user
username=shareolite
password=blog
max-messages=3
concatenation=true

# This is used by smsbox process. 
group = smsbox
bearerbox-host = localhost
# This port should be unique when multiple conf files are used.
# This port is used in the HTTP URL application which application calls.
sendsms-port = 10200
global-sender = 6666
log-file = "/kannel/log/smsbox.log"
log-level = 0
access-log = "/kannel/log/access.log"

# This is used for incoming messages from SMS center
group = sms-service
accepted-smsc = http
keyword = default
# When a message is received from SMS center this URL is called. Refer manual for wildcards details.
get-url=http://10.12.34.1/cgi-bin/SMSGW?&%t%p&%a&
max-messages=0


  • How to start kannel gateway process 

Now that you have installed Kannel gateway under /kannel directory and done with copying the above configuration file , we can start Kannel gateway process by executing below commands in a console

[root@shareolite ~]$ /kannel/bin/bearerbox   /kannel/cfg/sms1.conf &
[root@shareolite ~]$ /kannel/bin/smsbox   /kannel/cfg/sms1.conf &

Check the status of connection and SMPP messages exchanged in kannel logs generated under /kannel/log folder as defined in above configuration.


  • How to check the SMS center connection status

Kannel provides a utility to check the online connection status with SMS center . Execute the below command

[root@shareolite ~]$ GET "http://localhost:10000/status?password=shareolite"

where ,
 10000 -> kannel bearer box admin port
 shareolite -> is the management password defined under admin-password

Sample output as below : 

Kannel bearerbox version `1.4.3'.
Hostname shareolite.blogspot.com , IP 192.12.33.4
Libxml version 2.6.26.
Using native malloc.

Status: running, uptime 3d 23h 35m 28s
WDP: received 0 (0 queued), sent 0 (0 queued)

SMS: received 0 (0 queued), sent 3 (0 queued), store size -1
SMS: inbound (0.00,0.00,0.00) msg/sec, outbound (0.17,0.13,0.09) msg/sec

DLR: 0 queued, using internal storage
Box connections:
    smsbox:(none), IP 127.0.0.1 (0 queued), (on-line 3d 23h 35m 26s)

SMSC connections:

    kannel    SMPP:201.45.66.3:4776/4776:shareo: (online 344128s, rcvd 0, sent 3, failed 0, queued 0 msgs)

  • How to stop Kannel gateway process
This can be done in two ways. 

First method is a straight forward method of checking the status of bearerbox and smsbox process , get the process IDs and stop using kill command.

[root@shareolite ~]$ ps -ef|grep box
shareolite      987     1  0 Mar18 ?        00:00:21 /kannel/bin/bearerbox /kannel/cfg/sms1.conf
shareolite      992     1  0 Mar18 ?        00:00:19 /kannel/bin/smsbox /kannel/cfg/sms1.conf

[root@shareolite ~]$ kill -9 987 992

Second method is to use the kannel gateway shutdown command which can be invoked as below

[root@shareolite ~]$ GET "http://localhost:10000/shutdown?password=shareolite"

where ,
 10000 -> kannel bearer box admin port
 shareolite -> is the management password defined under admin-password

Now the main part ,


  • How to send SMS from a application 

To send SMS , kannel gateway smsbox URL has to be used . A sample URL is provided below

[root@shareolite ~]$ GET "http://127.0.0.1:10200/cgi-bin/sendsms?user=shareolite&pass=blog&text=Hello&to=123456789&from=Shareolite"

where ,
10200 is the send sms port defined in configuration file.
user=shareolite&pass=blog - are referred from the sendms-user group configurations
text= is the message content to be sent
to= is the destination mobile number
from= the sender identifier which will be displayed on subscriber handset

Hope this article is helpful to some Kannel gateway beginners and SMPP enthusiasts.
Comments

–>