Sunday, December 16, 2012

Steps to install Kannel SMS Gateway with SQLBox


Kannel :
Kannel is a compact and very powerful open source WAP and SMS gateway,WAP is used for Push service indications and mobile Internet connectivity.
WAP :
Wireless Application Protocol is a technical standard for accessing information over a mobile wireless network. WAP means a protocol that are used to connect wireless GPRS OR GSM with web browser by sending encoded message to mobile. By this web browser get the information of mobile device and start sending messages or emails through network.
Steps to install kannel with sqlbox:
1. To install kannel we need to install this essencial requirements.
Warning : run command with sudo user
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install bison
sudo apt-get install libmysqld-dev

sudo apt-get install libxml2-dev
2. Download gateway stable release version 1.4.3.

http://www.kannel.org/downloads/1.4.3/gateway-1.4.3.tar.gz
3. Extract gateway folder in any directory of your system. 
$ tar xfvz gateway-1.4.3.tar.gz
4. Goto gateway folder.
$ cd gateway-1.4.3/
5. Configure
The below command makes the shell run the script named ‘ configure ‘ which exists in the current directory. The configure script basically consists of many lines which are used to check some details about the machine on which the software is going to be installed. This script checks for lots of dependencies on your system. wait for the completion of the process.

$ ./configure --with-mysql
6. make
make command used to perform all necessary re-compilations. You can use make with any programming language whose compiler can be

run with a shell command. make command is used when we want to run any project which needs compilation of files.

$ make
7. make install
The install section happens to be only a part where the executables and other required files created during the last step (i.e. make) are copied into the required final directories on your machine. E.g. the executable that the user runs may be copied to the /usr/local/bin so that all users are able to run the software. Similarly all the other files are also copied to the standard directories in Linux. Remember that when you ran make, all the executables were created in the temporary directory where you had unzipped your original tarball. So when you run make install, these executables are copied to the final directories.

$ make install

8. Download sqlbox by typing the below command line.

$ svn co https://svn.kannel.org/sqlbox/trunk sqlbox

9. Extract sqlbox folder in gateway folder which was downloaded before. Run below mentioned commands to install sqlbox.

$cd sqlbox
$ ./configure
$ make

$ make install

Kannel installation with sqlbox is completed.

Now we need to configure both kannel.conf file and sqlbox.conf.
1. Copy this below code and paste in your /etc/kannel/kannel.conf file and change the details according to your needs.
#CORE
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = *****
status-password = *****
admin-allow-ip = "*.*.*.*"
wdp-interface-name = "*"
log-file = "/var/log/kannel/bearerbox.log"
#store-file = "/var/log/kannel/kannel.store"
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "*.*.*.*"
dlr-storage=mysql

#SMSBOX SETUP
group = smsbox
bearerbox-host = localhost
sendsms-port = 13013
bearerbox-port = 13001
sendsms-chars = "0123456789 +-"
global-sender = +91number
log-file = "/var/log/kannel/smsbox.log"
log-level = 0

# SEND-SMS USERS
group = sendsms-user
username = usernameToSendSms
password = passwordToSendSms
default-smsc = SMSC-ID
user-allow-ip ="*.*.*.*"

#mysql connection
group = mysql-connection
id = sqlbox-db
host = localhost
username = root
password = passwordOfMysql
database = dataBaseName
max-connections = 10

# DLR SETUP
#mysql connection
group = mysql-connection
id = mydlr
host = localhost
username = root
password = passwordOfMysql
database = dataBaseName
max-connections = 10

group = dlr-db
id = mydlr
table=dlr
field-smsc=smsc
field-timestamp=ts
field-destination=destination
field-source=source
field-service=service
field-url=url
field-mask=mask
field-status=status
field-boxc-id=boxc

# SMSC Fake
group = smsc
smsc = fake
port = 10000
connect-allow-ip = 127.0.0.1

# SMS SERVICE black-list
#group = sms-service
#keyword = black
#text = "You are not allowed to use this service, Go away!"
#catch-all = true

# SMSC SMPP
group = smsc
smsc-id = idForSmsc
smsc = smpp
host = **.**.**.**
port = portnumber
receive-port = 16400
smsc-username = username
smsc-password = password
system-type = type
system-id = id
address-range = ""

#SMS SERVICE GET-URL EXAMPLE
group = sms-service
keyword = default
send-sender = true
get-url = "http://localhost/receivesms?phone=%p&text=%a"

# SMS SERVICE Default
# there should be default always
#group = sms-service
#keyword = default
#text = "No service specified. "

Note: Remove # symbols if you need and change the value for that according to your requirement.

2. Copy the below code and paste in /etc/kannel/sqlbox.conf file and change the details according to your requirement.
SQL BOX CONFIG
group = sqlbox
id = sqlbox-db
smsbox-id = sqlbox
global-sender = ""
bearerbox-host = localhost
bearerbox-port = 13001
smsbox-port = 13002
smsbox-port-ssl = false
sql-log-table = sent_sms
sql-insert-table = send_sms
#log-file = "/var/log/kannel/kannel-sqlbox.log"
#log-level = 0
#ssl-client-certkey-file = ""
#ssl-server-cert-file = ""
#ssl-server-key-file = ""
#ssl-trusted-ca-file = ""

# Database connection examples. Please uncomment as needed
# Example MYSQL Connection
group = mysql-connection
id = sqlbox-db
host = localhost
username = root
password = passwordOfMysql
database = dataBase

# Example ORACLE Connection
#group = oracle-connection
#id = sqlbox-db
#username = myuser
#password = mypass
#tnsname = //localhost:1521/XE

# Example POSTGRESQL Connection
#group = pgsql-connection
#id = sqlbox-db
#id = sqlbox-db
#username = myuser
#password = mypass
#database = kannel
#host = localhost

# Example SDB Connection with some database URL examples
# *** Note: Uncomment only _one_ "url" line ***
#group = sdb-connection
#id = sqlbox-db
#url = mysql:host=localhost:db=kannel:uid=myuser:pwd=mypass
#url = sqlite:db=/path/to/kannel.db
#url = sqlite3:db=/path/to/kannel3.db

# Example SQLITE 2 Connection
#group = sqlite-connection
#id = sqlbox-db
#database = /path/to/kannel.db
#max-connections = 1

# Example SQLITE 3 Connection
#group = sqlite3-connection
#id = sqlbox-db
#database = /path/to/kannel.db
#max-connections = 1

Installation and Configuration is completed now. We should run the Bearerbox, Sqlbox and Smsbox to send a sms from the kannel using smpp account.

Note: Open 3 Termials for 3 boxes individually
Starting the Bearerbox: (type this command in terminal as super user)
bearerbox -v 0 /etc/kannel/kannel.conf
Starting the Sqlbox: (type this command in terminal as super user)
sqlbox -v 0 /etc/kannel/sqlbox.conf
Stargin the Smsbox:  (type this command in terminal as super user)
smsbox -v 0 /etc/kannel/kannel.conf
if boxes are running properly without any errors then you succefully installed kannel with sqlbox. if you got any errors you can post a comment here....
Sending first sms:
Open MySql or PhpMyAdmin and login with your details.
Then open the send_sms table and insert a record.
Note: No need to insert all the fields. Mandatory fields are 
1. Sender
2. Reciever
3. Text (Message)
4. SMSC_ID (which is used in kannel.conf file to identify the smsc_id)
5. Account (Username of smsc)
Then automatically the message goes to the particular number.
If you want to check the status of your messages open browser and type the url in the address bar
http://localhost:13000/status?password=status-password
(here status-password is the password which is given in the kannel.conf file)

14 comments:

  1. I am very thankful to the author to write this fruitful information.It is worth sharing for other users.Thanks once again
    sms gateway

    ReplyDelete
  2. Hope you are doing well. We are looking for someone who can help us to install Kannel in our system. If you are interested to take up this task, please contact us krraju82@gmail.com or Skype: rhythasupport2.

    Thanks,
    Raju

    ReplyDelete
  3. Hi,
    it's mandatory init smsbox if I want send a sms by inserting a record in send-sms table?

    ReplyDelete
  4. Please don't follow the steps,

    Not working time waste

    ReplyDelete
  5. Thanks for writing this helpful article.. ..currently busking on the glory of sending my first sms from sqlbox... ;)

    ReplyDelete
  6. is kannnel capaple of handeling mo's

    ReplyDelete
  7. Hi thanks to the author, it is really nice for beginner like me. I am stack, i can locate kannel in my /etc hence I can't even change sqlbox.conf file. can any body help me?

    Thanks
    JP

    ReplyDelete
  8. My service provider has provided me SSL certificate now, I am able to configure kannel without SSL but now how to configure with .crt SSL certificate?

    ReplyDelete
  9. ~/sqlbox# make install
    Making install in gw
    make[1]: entrant dans le répertoire « /home/mohamed/sqlbox/gw »
    gcc -DHAVE_CONFIG_H -I. -I.. -I../gw -I../gw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -I/usr/local/include/kannel -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES= -I/usr/include/libxml2 -I/usr/include/mysql -MT sqlbox_mysql.o -MD -MP -MF .deps/sqlbox_mysql.Tpo -c -o sqlbox_mysql.o sqlbox_mysql.c
    sqlbox_mysql.c: In function ‘mysql_fetch_msg’:
    sqlbox_mysql.c:148:21: error: ‘struct sms’ has no member named ‘meta_data’
    msg->sms.meta_data = octstr_null_create(row[26]);
    ^
    sqlbox_mysql.c: In function ‘mysql_fetch_msg_list’:
    sqlbox_mysql.c:213:25: error: ‘struct sms’ has no member named ‘meta_data’
    msg->sms.meta_data = octstr_null_create(row[26]);
    ^
    sqlbox_mysql.c: In function ‘mysql_save_msg’:
    sqlbox_mysql.c:266:74: error: ‘struct sms’ has no member named ‘meta_data’
    st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_str(msg->sms.foreign_id));
    ^
    sqlbox_mysql.c:252:76: note: in definition of macro ‘st_str’
    #define st_str(x) (stuffer[stuffcount++] = get_string_value_or_return_null(x))
    ^
    sqlbox_mysql.c: In function ‘mysql_save_list’:
    sqlbox_mysql.c:297:82: error: ‘struct sms’ has no member named ‘meta_data’
    st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_str(msg->sms.foreign_id));
    ^
    sqlbox_mysql.c:252:76: note: in definition of macro ‘st_str’
    #define st_str(x) (stuffer[stuffcount++] = get_string_value_or_return_null(x))
    ^
    make[1]: *** [sqlbox_mysql.o] Erreur 1
    make[1]: quittant le répertoire « /home/user/sqlbox/gw »
    make: *** [install-recursive] Erreur 1

    ReplyDelete
  10. can we install the same in ubuntu 14.04 desktop version or ubauntu 14.04 sever version

    or it require live dedcited server ?

    please ans urgently

    ReplyDelete
    Replies
    1. Yes you can install it in ubuntu 14.04 but i suggest you download the latest version of kannel which is gateway-1.4.4 you can get it throught this link http://www.kannel.org/download.shtml

      Delete
  11. All ok, when I insert query in send_sms table , the sms sent to recipient and entry is updated in sent_sms table. but the STATUS field is not updating. what I am missing here?

    ReplyDelete
  12. hai nag , what i like about your blog is that you use very simple and precise code to let people understand very clearly on things about bulk sms gateway kannel

    ReplyDelete
  13. I have installed kannel successfully with sqlbox. But when i insert a record the bearerbox terminal displaying a message:

    2017-01-23 01:01:41 [3823] [7] DEBUG: sms_router: gwlist_len = 2
    2017-01-23 01:01:41 [3823] [7] DEBUG: sms_router: handling message (0x7f9c28001c30 vs 0x7f9c28001c30)
    2017-01-23 01:01:41 [3823] [7] DEBUG: Routing failed, re-queued.
    2017-01-23 01:01:41 [3823] [7] DEBUG: sms_router: handling message (0x7f9c28002150 vs 0x7f9c28001c30)
    2017-01-23 01:01:41 [3823] [7] DEBUG: Routing failed, re-queued.
    2017-01-23 01:01:41 [3823] [7] DEBUG: sms_router: handling message (0x7f9c28001c30 vs 0x7f9c28001c30)
    2017-01-23 01:01:41 [3823] [7] DEBUG: Routing failed, re-queued.
    2017-01-23 01:01:41 [3823] [7] DEBUG: sms_router: time to sleep 30.00 secs.


    Please help me to resolve this issue.

    ReplyDelete