Hi Scott,
Maybe I'm under false assumptions... What I'm trying to capture is all
the data into a database. I need a few fields: phone number,
date/time, message content
MT messages are sent by you, using kannel. The solution here is simple:
write the details to a database before you send them to kannel.
MO messages are delivered to the get-url parameter specified in your
sms-service group.
I use the following sms service with the keyword-regex .* as I handle all
my message switching in my app outside of kannel (I simply use kannel as
an SMPP transport and nothing more):
# SERVICES
group = sms-service
keyword =
keyword-regex = .*
catch-all = yes
max-messages = 0
accept-x-kannel-headers=1
get-url =
"http://myserver.com/concatenate_mo.php?from=%p&to=%Q&msg=%a&udh=%u&id=%I"
The reason I use the id=%I parameter there is because the "to" parameter
doesn't work (it's possibly been fixed in a later version of kannel but
there's no way I'm upgrading the software on a production machine when I
already have a workaround :)
I've attached the concatenate_mo.php script I have written which deals
with the UDH to stick long messages back together (again, this may be
present in later versions of kannel but I haven't bothered checking since
I've got no problems with my present solution).
The real hack is in the function getDestination which uses the "id"
parameter obtained from %I in the get-url parameter to find out what the
destination number, ie. the number that this message came in on, was by
grepping the kannel log file. Ugly as hell, but it's worked 100% reliably
for me for the past 3 years so I'm not about to go changing it.
Your mileage may vary though :)
Cheers,
Iain
On 6/13/10, Nikos Balkanas <[email protected]> wrote:
Hi,
Your problem is that you mix up MOs with MTs. The reply to an MO is not an
MT, just an MO reply. MTs are push SMS such as those sent through your
/sendsms HTTP interface. MTs get DLRs according to their specified DLR-mask.
MOs don't.
Be aware, some SMScs do not send DLRs even in the case of MTs to modems,
especially if they are mobile phones.
BR,
Nikos
----- Original Message -----
From: Scott Geller
To: Nikos Balkanas
Cc: [email protected]
Sent: Sunday, June 13, 2010 6:59 PM
Subject: Re: getting MO and MT data into a database
Thanks Nikos!
Below are new logs, which include start up, one MO (which has an MT reply
from kannel) and shutdown. Only thing I pulled was the phone numbers
I have the logs all set to level zero (debug level).
Really appreciate your help!!
Thanks
Scott
#############
bearerbox_access.log
#############
2010-06-13 11:08:28 Log begins
2010-06-13 11:14:03 Receive SMS [SMSC:AT2[/dev/rfcomm0]] [SVC:] [ACT:]
[BINF:] [FID:] [from:+1443xxxxxxx] [to:1234] [flags:-1:0:-1:0:-1]
[msg:4:Test] [udh:0:]
2010-06-13 11:14:09 Sent SMS [SMSC:AT2[/dev/rfcomm0]] [SVC:] [ACT:]
[BINF:] [FID:] [from:1234] [to:+1443xxxxxxx] [flags:-1:0:-1:-1:-1]
[msg:14:testing 123455] [udh:0:]
2010-06-13 11:28:56 Log ends
################
bearerbox.log
################
2010-06-13 11:08:28 [4663] [0] INFO: Added logfile
`/var/log/kannel/bearerbox.log' with level `0'.
2010-06-13 11:08:28 [4663] [0] INFO: Started access logfile
`/var/log/kannel/bearerbox_access.log'.
2010-06-13 11:08:28 [4663] [0] INFO: SSL not supported, no SSL
initialization done.
2010-06-13 11:08:28 [4663] [0] INFO: HTTP: Opening server at port 13000.
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 1
(gwlib/fdset.c:poller)
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 2
(gwlib/http.c:server_thread)
2010-06-13 11:08:28 [4663] [2] DEBUG: Thread 2
(gwlib/http.c:server_thread) maps to pid 4663.
2010-06-13 11:08:28 [4663] [3] DEBUG: Thread 3
(gw/bb_http.c:httpadmin_run) maps to pid 4663.
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 3
(gw/bb_http.c:httpadmin_run)
2010-06-13 11:08:28 [4663] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller) maps
to pid 4663.
2010-06-13 11:08:28 [4663] [0] DEBUG: starting smsbox connection module
2010-06-13 11:08:28 [4663] [0] INFO: BOXC: 'smsbox-max-pending' not set,
using default (100).
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 4
(gw/bb_boxc.c:sms_to_smsboxes)
2010-06-13 11:08:28 [4663] [4] DEBUG: Thread 4
(gw/bb_boxc.c:sms_to_smsboxes) maps to pid 4663.
2010-06-13 11:08:28 [4663] [5] DEBUG: Thread 5 (gw/bb_boxc.c:smsboxc_run)
maps to pid 4663.
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 5
(gw/bb_boxc.c:smsboxc_run)
2010-06-13 11:08:28 [4663] [0] INFO: Set SMS resend frequency to 60
seconds.
2010-06-13 11:08:28 [4663] [0] INFO: SMS resend retry set to unlimited.
2010-06-13 11:08:28 [4663] [0] DEBUG: smsbox MO concatenated message
handling enabled
2010-06-13 11:08:28 [4663] [0] INFO: DLR rerouting for smsc id <(null)>
disabled.
2010-06-13 11:08:28 [4663] [0] INFO: AT2[/dev/rfcomm0]: configuration
doesn't show modemtype. will autodetect
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 6
(gw/smsc/smsc_at.c:at2_device_thread)
2010-06-13 11:08:28 [4663] [6] DEBUG: Thread 6
(gw/smsc/smsc_at.c:at2_device_thread) maps to pid 4663.
2010-06-13 11:08:28 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: detecting modem
type
2010-06-13 11:08:28 [4663] [6] INFO: AT2[/dev/rfcomm0]: opening device
2010-06-13 11:08:28 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: device opened.
Telnet mode = 0
2010-06-13 11:08:28 [4663] [0] DEBUG: Started thread 7
(gw/bb_smscconn.c:sms_router)
2010-06-13 11:08:28 [4663] [0] INFO:
----------------------------------------
2010-06-13 11:08:28 [4663] [0] INFO: Kannel bearerbox II version 1.4.3
starting
2010-06-13 11:08:28 [4663] [0] INFO: MAIN: Start-up done, entering
mainloop
2010-06-13 11:08:28 [4663] [0] DEBUG: AT2[/dev/rfcomm0]: start called
2010-06-13 11:08:28 [4663] [7] DEBUG: Thread 7
(gw/bb_smscconn.c:sms_router) maps to pid 4663.
2010-06-13 11:08:29 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: device opened
2010-06-13 11:08:29 [4663] [6] INFO: AT2[/dev/rfcomm0]: speed set to
115200
2010-06-13 11:08:29 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- AT
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT&F^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- AT&F
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ATE0^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- ATE0
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ATI^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- Nokia
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: Cannot detect
modem, using generic
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: Reading modem
definitions from <kannele.conf>
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: Found <1> modems
in config
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CSMS=?^M
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CSMS: (0,1)
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:31 [4663] [6] INFO: AT2[/dev/rfcomm0]: Phase 2+ is
supported
2010-06-13 11:08:31 [4663] [6] INFO: AT2[/dev/rfcomm0]: Closing device
2010-06-13 11:08:31 [4663] [6] INFO: AT2[/dev/rfcomm0]: opening device
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: device opened.
Telnet mode = 0
2010-06-13 11:08:31 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: device opened
2010-06-13 11:08:31 [4663] [6] INFO: AT2[/dev/rfcomm0]: Logging in
2010-06-13 11:08:32 [4663] [6] INFO: AT2[/dev/rfcomm0]: init device
2010-06-13 11:08:32 [4663] [6] INFO: AT2[/dev/rfcomm0]: speed set to
115200
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ATZ^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- AT
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT&F^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- AT&F
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ATE0^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- ATE0
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+IFC=2,2^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CPIN?^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CPIN: READY
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CMGF=0^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CSMS=?^M
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CSMS: (0,1)
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:32 [4663] [6] INFO: AT2[/dev/rfcomm0]: Phase 2+ is
supported
2010-06-13 11:08:32 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CSMS=1^M
2010-06-13 11:08:33 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CSMS: 1,1,1
2010-06-13 11:08:33 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:33 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: -->
AT+CNMI=1,2,0,1,0^M
2010-06-13 11:08:33 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:08:33 [4663] [6] INFO: AT2[/dev/rfcomm0]: AT SMSC
successfully opened.
2010-06-13 11:09:19 [4663] [5] INFO: Client connected from <127.0.0.1>
2010-06-13 11:09:19 [4663] [5] DEBUG: Started thread 8
(gw/bb_boxc.c:function)
2010-06-13 11:09:19 [4663] [8] DEBUG: Thread 8 (gw/bb_boxc.c:function)
maps to pid 4663.
2010-06-13 11:09:19 [4663] [8] DEBUG: Started thread 9
(gw/bb_boxc.c:boxc_sender)
2010-06-13 11:09:19 [4663] [9] DEBUG: Thread 9 (gw/bb_boxc.c:boxc_sender)
maps to pid 4663.
2010-06-13 11:09:19 [4663] [8] DEBUG: boxc_receiver: got boxc_id <sqlbox>
from <127.0.0.1>
2010-06-13 11:09:40 [4663] [5] INFO: Client connected from <127.0.0.1>
2010-06-13 11:09:40 [4663] [5] DEBUG: Started thread 10
(gw/bb_boxc.c:function)
2010-06-13 11:09:40 [4663] [10] DEBUG: Thread 10 (gw/bb_boxc.c:function)
maps to pid 4663.
2010-06-13 11:09:40 [4663] [10] DEBUG: Started thread 11
(gw/bb_boxc.c:boxc_sender)
2010-06-13 11:09:40 [4663] [11] DEBUG: Thread 11
(gw/bb_boxc.c:boxc_sender) maps to pid 4663.
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CMT: ,23
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <--
07912180958719F7040B914134670628F500000160311121406904D4F29C0E
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: received message
from SMSC: +12085978917
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: Numeric sender
(international) <+1443xxxxxxx>
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: User data length
read as (4)
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: Udh decoding done
len=4 udhi=0 udhlen=0 udh=''
2010-06-13 11:14:03 [4663] [11] DEBUG: send_msg: sending msg to box:
<127.0.0.1>
2010-06-13 11:14:03 [4663] [11] DEBUG: boxc_sender: sent message to
<127.0.0.1>
2010-06-13 11:14:03 [4663] [10] DEBUG: boxc_receiver: sms received
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CNMA^M
2010-06-13 11:14:03 [4663] [10] DEBUG: send_msg: sending msg to box:
<127.0.0.1>
2010-06-13 11:14:03 [4663] [10] DEBUG: boxc_receiver: got ack
2010-06-13 11:14:03 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]:
TP-Validity-Period: 24.0 hours
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> AT+CMGS=27^M
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- >
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: send command
status: 1
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: -->
0011000B914134670628F50000A70EF4F29C9E769F4131D98C56AB01
2010-06-13 11:14:05 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: --> ^Z
2010-06-13 11:14:09 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- >
2010-06-13 11:14:09 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- +CMGS: 37
2010-06-13 11:14:09 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: <-- OK
2010-06-13 11:14:09 [4663] [6] DEBUG: AT2[/dev/rfcomm0]: send command
status: 0
2010-06-13 11:14:10 [4663] [10] DEBUG: boxc_receiver: heartbeat with load
value 0 received
2010-06-13 11:28:53 [4663] [0] WARNING: Killing signal or HTTP admin
command received, shutting down...
2010-06-13 11:28:53 [4663] [0] DEBUG: Shutting down Kannel...
2010-06-13 11:28:53 [4663] [0] DEBUG: shutting down smsc
2010-06-13 11:28:53 [4663] [0] DEBUG: AT2[/dev/rfcomm0]: Shutting down
SMSCConn, slow
2010-06-13 11:28:53 [4663] [0] DEBUG: shutting down udp
2010-06-13 11:28:55 [4663] [6] INFO: AT2[/dev/rfcomm0]: Closing device
2010-06-13 11:28:55 [4663] [9] DEBUG: send_msg: sending msg to boxc:
<sqlbox>
2010-06-13 11:28:55 [4663] [6] DEBUG: Thread 6
(gw/smsc/smsc_at.c:at2_device_thread) terminates.
2010-06-13 11:28:55 [4663] [4] DEBUG: Thread 4
(gw/bb_boxc.c:sms_to_smsboxes) terminates.
2010-06-13 11:28:55 [4663] [11] DEBUG: send_msg: sending msg to box:
<127.0.0.1>
2010-06-13 11:28:55 [4663] [11] DEBUG: Thread 11
(gw/bb_boxc.c:boxc_sender) terminates.
2010-06-13 11:28:55 [4663] [9] DEBUG: Thread 9 (gw/bb_boxc.c:boxc_sender)
terminates.
2010-06-13 11:28:55 [4663] [10] INFO: Connection closed by the box
<127.0.0.1>
2010-06-13 11:28:55 [4663] [10] DEBUG: Thread 10 (gw/bb_boxc.c:function)
terminates.
2010-06-13 11:28:55 [4663] [8] INFO: Connection closed by the box
<127.0.0.1>
2010-06-13 11:28:55 [4663] [8] DEBUG: Thread 8 (gw/bb_boxc.c:function)
terminates.
2010-06-13 11:28:55 [4663] [7] DEBUG: Thread 7
(gw/bb_smscconn.c:sms_router) terminates.
2010-06-13 11:28:56 [4663] [5] DEBUG: Thread 5 (gw/bb_boxc.c:smsboxc_run)
terminates.
2010-06-13 11:28:56 [4663] [0] INFO: All flow threads have died, killing
core
2010-06-13 11:28:56 [4663] [0] DEBUG: Waiting for 2
(gwlib/http.c:server_thread) to terminate
2010-06-13 11:28:56 [4663] [3] DEBUG: HTTP: No clients with requests,
quitting.
2010-06-13 11:28:56 [4663] [3] DEBUG: Thread 3
(gw/bb_http.c:httpadmin_run) terminates.
2010-06-13 11:28:56 [4663] [2] DEBUG: Thread 2
(gwlib/http.c:server_thread) terminates.
2010-06-13 11:28:56 [4663] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller)
terminates.
2010-06-13 11:28:56 [4663] [0] DEBUG: final clean-up for SMSCConn
2010-06-13 11:28:56 [4663] [0] DEBUG: smsbox MO concatenated message
handling cleaned up
2010-06-13 11:28:56 [4663] [0] INFO: Total WDP messages: received 0, sent
0
2010-06-13 11:28:56 [4663] [0] INFO: Total SMS messages: received 1, sent
1
2010-06-13 11:28:56 [4663] [0] DEBUG: Immutable octet strings: 268.
#################
smsbox_access.log
################
2010-06-13 11:09:40 Log begins
2010-06-13 11:14:03 SMS request sender:+1443xxxxxxx request: 'Test' fixed
answer: 'testing 123455'
2010-06-13 11:28:55 Log ends
##################
smsbox.log
##################
2010-06-13 11:09:40 [4802] [0] INFO: Added logfile
`/var/log/kannel/smsbox.log' with level `0'.
2010-06-13 11:09:40 [4802] [0] INFO: Logging accesses to
'/var/log/kannel/smsbox_access.log'.
2010-06-13 11:09:40 [4802] [0] INFO: Started access logfile
`/var/log/kannel/smsbox_access.log'.
2010-06-13 11:09:40 [4802] [0] INFO: HTTP: Opening server at port 13012.
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 1
(gwlib/fdset.c:poller)
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 2
(gwlib/http.c:server_thread)
2010-06-13 11:09:40 [4802] [0] INFO: Set up send sms service at port 13012
2010-06-13 11:09:40 [4802] [2] DEBUG: Thread 2
(gwlib/http.c:server_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller) maps
to pid 4802.
2010-06-13 11:09:40 [4802] [3] DEBUG: Thread 3
(gw/smsbox.c:sendsms_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 3
(gw/smsbox.c:sendsms_thread)
2010-06-13 11:09:40 [4802] [0] DEBUG:
----------------------------------------------
2010-06-13 11:09:40 [4802] [0] DEBUG: Kannel smsbox version 1.4.3 starting
2010-06-13 11:09:40 [4802] [0] DEBUG: dumping group (sendsms-user):
2010-06-13 11:09:40 [4802] [0] DEBUG: <name> = <tester sendsms-user>
2010-06-13 11:09:40 [4802] [0] DEBUG: <group> = <sendsms-user>
2010-06-13 11:09:40 [4802] [0] DEBUG: <username> = <tester>
2010-06-13 11:09:40 [4802] [0] DEBUG: <password> = <foobar>
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 4
(gw/smsbox.c:obey_request_thread)
2010-06-13 11:09:40 [4802] [4] DEBUG: Thread 4
(gw/smsbox.c:obey_request_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 5
(gw/smsbox.c:url_result_thread)
2010-06-13 11:09:40 [4802] [5] DEBUG: Thread 5
(gw/smsbox.c:url_result_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 6
(gw/smsbox.c:http_queue_thread)
2010-06-13 11:09:40 [4802] [6] DEBUG: Thread 6
(gw/smsbox.c:http_queue_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [0] INFO: Connected to bearerbox at localhost
port 13011.
2010-06-13 11:09:40 [4802] [7] DEBUG: Thread 7
(gw/heartbeat.c:heartbeat_thread) maps to pid 4802.
2010-06-13 11:09:40 [4802] [0] DEBUG: Started thread 7
(gw/heartbeat.c:heartbeat_thread)
2010-06-13 11:14:03 [4802] [4] DEBUG: no match found: ^[ ]*(nop)[ ]*
2010-06-13 11:14:03 [4802] [4] INFO: Starting to service <Test> from
<+1443xxxxxxx> to <1234>
2010-06-13 11:14:03 [4802] [4] DEBUG: formatted text answer: <testing
123455>
2010-06-13 11:14:03 [4802] [4] DEBUG: message length 14, sending 1
messages
2010-06-13 11:14:03 [4802] [0] DEBUG: Got ACK (0) of
40925309-4e8a-4ef8-b09d-688194e08a82
2010-06-13 11:14:03 [4802] [0] DEBUG: No client - multi-send or ACK to
pull-reply
2010-06-13 11:28:55 [4802] [0] INFO: Bearerbox told us to die
2010-06-13 11:28:55 [4802] [0] INFO: Received (and handled?) 1 requests in
892 seconds (0.00 per second)
2010-06-13 11:28:55 [4802] [0] INFO: Kannel smsbox terminating.
2010-06-13 11:28:55 [4802] [7] DEBUG: Thread 7
(gw/heartbeat.c:heartbeat_thread) terminates.
2010-06-13 11:28:55 [4802] [0] DEBUG: Waiting for 2
(gwlib/http.c:server_thread) to terminate
2010-06-13 11:28:55 [4802] [3] DEBUG: HTTP: No clients with requests,
quitting.
2010-06-13 11:28:55 [4802] [3] DEBUG: Thread 3
(gw/smsbox.c:sendsms_thread) terminates.
2010-06-13 11:28:55 [4802] [2] DEBUG: Thread 2
(gwlib/http.c:server_thread) terminates.
2010-06-13 11:28:55 [4802] [1] DEBUG: Thread 1 (gwlib/fdset.c:poller)
terminates.
2010-06-13 11:28:55 [4802] [0] DEBUG: Waiting for 4
(gw/smsbox.c:obey_request_thread) to terminate
2010-06-13 11:28:55 [4802] [4] DEBUG: Thread 4
(gw/smsbox.c:obey_request_thread) terminates.
2010-06-13 11:28:55 [4802] [6] DEBUG: Thread 6
(gw/smsbox.c:http_queue_thread) terminates.
2010-06-13 11:28:55 [4802] [0] DEBUG: Waiting for 5
(gw/smsbox.c:url_result_thread) to terminate
2010-06-13 11:28:55 [4802] [5] DEBUG: Thread 5
(gw/smsbox.c:url_result_thread) terminates.
2010-06-13 11:28:55 [4802] [0] DEBUG: Immutable octet strings: 191.
#################
kannel-sqlbox.log
#################
2010-06-13 11:09:18 [4737] [0] INFO: Added logfile
`/var/log/kannel/kannel-sqlbox.log' with level `0'.
2010-06-13 11:09:18 [4737] [0] INFO: PGSQL: Connected to server at
'localhost'.
2010-06-13 11:09:19 [4737] [0] ERROR: PGSQL: ERROR: relation "sent_sms"
already exists
2010-06-13 11:09:19 [4737] [0] ERROR: PGSQL: ERROR: relation "send_sms"
already exists
2010-06-13 11:09:19 [4737] [0] DEBUG: Started thread 1
(sqlbox.c:sql_to_bearerbox)
2010-06-13 11:09:19 [4737] [1] DEBUG: Thread 1 (sqlbox.c:sql_to_bearerbox)
maps to pid 4737.
2010-06-13 11:09:19 [4737] [1] INFO: Connected to bearerbox at localhost
port 13011.
2010-06-13 11:09:19 [4737] [1] DEBUG: Started thread 2
(sqlbox.c:bearerbox_to_sql)
2010-06-13 11:09:19 [4737] [2] DEBUG: Thread 2 (sqlbox.c:bearerbox_to_sql)
maps to pid 4737.
2010-06-13 11:28:55 [4737] [2] DEBUG: bearerbox_to_sql: connection to
bearerbox died.
2010-06-13 11:28:55 [4737] [2] DEBUG: Thread 2 (sqlbox.c:bearerbox_to_sql)
terminates.
2010-06-13 11:28:55 [4737] [1] DEBUG: Thread 1 (sqlbox.c:sql_to_bearerbox)
terminates.
2010-06-13 11:29:04 [4737] [0] DEBUG: Immutable octet strings: 47.
2010/6/12 Nikos Balkanas <[email protected]>
Hi,
I won't comment on sqlbox. Regarding bb. Please post bb logs in maximum
detail from when receiving DLR from smsc. What kannel version do you have?
BR,
Nikos
----- Original Message ----- From: Scott Geller
To: [email protected]
Sent: Saturday, June 12, 2010 7:00 AM
Subject: getting MO and MT data into a database
Guys,
I've been working on this for days and cant get it working. I'm trying
to get the data from kannel into postgres... either with sqlbox or with BB.
regarding sqlbox:
I have sqlbox working and when I insert a line into the send_sms table,
everything works on the MT side. But I'm under the impression that if if
start sqlbox before I start smsbox, the MO data should also be captured. I
THINK this data would be ritcher than the BB data based on what I've seen
with the table structures
regarding BB:
I am not seeing any data posted into my table
regarding postgres:
I can query the connections and can see that kannel is connecting:
select * from pg_stat_activity;
33362 dlr 27524 10 postgres select * from pg_stat_activity false
2010-06-11 23:38:50.522682 2010-06-11 23:38:50.524477 2010-06-10
21:13:36.271735 127.0.0.1 53776
33362 dlr 9087 10 postgres <IDLE> false 2010-06-11 22:58:51.365257
127.0.0.1 58058
33362 dlr 9100 10 postgres <IDLE> false 2010-06-11 23:38:49.857646
2010-06-11 22:58:59.383983 127.0.0.1 58059
33362 dlr 29443 10 postgres <IDLE> false 2010-06-11 20:45:46.143249
2010-06-10 21:34:24.909323 127.0.0.1 39551
33362 dlr 32004 10 postgres <IDLE> false 2010-06-11 23:02:00.430404
2010-06-11 20:44:41.274866 127.0.0.1 37469
I have my dlr table in two schemas (public and dlr)... the schemas are
in a database called dlr.
Here's the create table code for the schema dlr:
CREATE TABLE dlr.dlr (smsc varchar, ts varchar, destination varchar,
source varchar, service varchar, url varchar, mask varchar, status varchar,
boxc varchar);
I'm not seeing any errors either on the postgres side or the kannel side
that may indicate a problem
here's my config files:
group = sqlbox
id = sqlbox-db
smsbox-id = sqlbox
bearerbox-host = localhost
bearerbox-port = 13011
smsbox-port = 13099
sql-log-table = sent_sms
sql-insert-table = send_sms
log-file = "/var/log/kannel/kannel-sqlbox.log"
log-level = 0
group = pgsql-connection
id = sqlbox-db
username = postgres
password = postgres
database = dlr
host = localhost
max-connections = 1
port=5432
######################
group = core
admin-port = 13000
admin-password = bar
smsbox-port = 13011
log-file = "/var/log/kannel/bearerbox.log"
log-level = 0
access-log = "/var/log/kannel/bearerbox_access.log"
dlr-storage = pgsql
group = smsc
smsc = at
device = /dev/rfcomm0
#speed = 9600
speed = 115200
group = smsbox
bearerbox-host = localhost
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/smsbox_access.log"
bearerbox-port = 13011
sendsms-port = 13012
group = modems
id = generic
name = "Generic Modem"
group = sendsms-user
username = tester
password = foobar
name = "tester sendsms-user"
group = sms-service
keyword = nop
text = "You asked nothing and I did it!"
catch-all = true
group = sms-service
keyword = default
text = "testing 123455"
group = pgsql-connection
id = mydlr
#host = localhost
host = 127.0.0.1
username = postgres
password = postgres
database = dlr
max-connections = 1
port = 5432
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
--
Sent from my mobile device
<?php
function writeLog($msg)
{
echo $msg.PHP_EOL;
}
/**
* My get-url parameter in the sms-service group looks like this:
* get-url =
"http://myserver.com/antenna/concatenate_mo.php?from=%p&to=%Q&msg=%a&udh=%u&id=%I";
* FOR TESTING you can include fake_to ... both numbers should have +
*/
//INITIALISE
define('CACHE','cache/');//must be writable by the web user
define('DEBUG',0);
define('MULTIPART_TIMEOUT',600);//in seconds
$to_dump = '';
//BUFFER OUTPUT FOR DEBUGGING
ob_start();
//CLEAR ANY OLD MULTIPART MESSAGES
clearOldMultipartMessages();
//IF WE'VE GOT A USER DATA HEADER AND IT'S NOT A BUSINESS CARD
$udh_test = preg_split('//', $_GET['udh'], -1, PREG_SPLIT_NO_EMPTY);
$str = '';
foreach($udh_test as $i => $c)
$str .= ord($c);
if($str == '6543524400')
$is_business_card = 1;
else
$is_business_card = 0;
if($_GET['udh']&&!$is_business_card)
{
$queue = getQueue();
//SPLIT UP THE CHARACTERS OF THE UDH
$udh = preg_split('//', $_GET['udh'], -1, PREG_SPLIT_NO_EMPTY);
//GET THE RELEVANT PARAMETERS
$num_parts = ord($udh[4]);
$cur_part = ord($udh[5]);
$msg_id = ord($udh[3]);
writeDebug('got: '.$msg_id);
//IF THIS ID ISN'T ALREADY PRESENT IN THE QUEUE
if(!isset($queue[$msg_id]))
{
writeDebug('creating new array for: '.$msg_id);
//CREATE THE QUEUE FOR THIS ID
$queue[$msg_id] = array();
$queue[$msg_id]['from'] = $_GET['from'];
$queue[$msg_id]['to'] = getDestination();
$queue[$msg_id]['time'] = time();
$queue[$msg_id]['msg'] = array();
}
//UPDATE THE QUEUE WITH THE NEW MESSAGE PART
$queue[$msg_id]['msg'][$cur_part] = $_GET['msg'];
writeDebug('writing: '.$cur_part.' as '.$_GET['msg']);
//IF WE'RE DONE RECEIVING
if(count($queue[$msg_id]['msg']) == $num_parts)
{
//PUT THE MESSAGE IN THE CORRECT FORMAT FOR USE BELOW
$to_dump = $queue[$msg_id];
ksort($to_dump['msg']);
$to_dump['msg'] = implode('',$to_dump['msg']);
writeDebug('num: '.$num_parts.' == count:
'.count($queue[$msg_id]['msg']));
//REMOVE THIS FROM THE QUEUE NOW
unset($queue[$msg_id]);
writeDebug('finished: '.$msg_id.' as '.$_GET['msg']);
writeDebug('imploded: '.$to_dump['msg'].' as '.$_GET['msg']);
}
//SAVE THE QUEUE
saveQueue($queue);
}
//OTHERWISE THIS WAS NOT A LONG MO
else
{
writeDebug('non-multipart SMS');
//PUT IT IN THE CORRECT FORMAT FOR USE BELOW
$to_dump = array();
$to_dump['from'] = $_GET['from'];
$to_dump['to'] = getDestination();
$to_dump['msg'] = $_GET['msg'];
}
//DID WE GET EITHER A FINISHED CONCATENATED MO OR A NON CONCATENATED MO?
if($to_dump)
{
//YEP, SO NOW DO WHAT YOU WANT WITH THE MESSAGE - WRITE TO A DB OR
SOMETHING
if(DEBUG)
print_r($to_dump);
$log = date('Y-m-d H:i:s').': '.$to_dump['from'].' to
'.$to_dump['to'].': '.cleanMessage($to_dump['msg']).PHP_EOL;
$fp = fopen(CACHE.'dump.txt','a+');
fwrite($fp,$log);
fclose($fp);
$from = str_replace('+','',$to_dump['from']);
$to = str_replace('+','',$to_dump['to']);
$msg = urlencode(cleanMessage($to_dump['msg']));
$msg_id = $_GET['id'];//CAN BE USED TO DEDUPLICATE
writeToDbOrSomething($from,$to,$msg,$msg_id);
}
$data = ob_get_clean();
if(DEBUG)
{
$fp = fopen(CACHE.'debug.txt','a+');
fwrite($fp,PHP_EOL.$data);
fclose($fp);
}
//MASSIVE HACK TO GET THE DESTINATION NUMBER
function getDestination()
{
if($fake_to = $_GET['fake_to'])
$ret = $fake_to;
else
{
$id = $_GET['id'];
$ret = trim(shell_exec('egrep "'.$id.'" /tmp/access.log | sed
"s/.*to:\+\([0-9]*\).*/+\1/g"'));
}
return $ret;
}
function cleanMessage($msg)
{
$msg = str_replace(chr(161),'@',$msg);
$msg = str_replace(chr(164),'$',$msg);
$msg = str_replace(chr(139),'^',$msg);
$msg = str_replace(chr(167),'_',$msg);
return $msg;
}
function clearOldMultipartMessages()
{
$queue = getQueue();
$now = time();
foreach($queue as $id => $data)
{
$diff = $now - $data['time'];
if($diff >= MULTIPART_TIMEOUT)
unset($data[$id]);
}
saveQueue($queue);
}
function getQueue()
{
waitForQueue();
lockQueue();
//UNSERIALIZE OUR QUEUE ARRAY IF ONE EXISTS
if(file_exists(CACHE.'multipart_queue.txt'))
{
writeDebug('existing queue');
$queue =
unserialize(file_get_contents(CACHE.'multipart_queue.txt'));
}
else
{
writeDebug('creating new queue');
$queue = array();
}
return $queue;
}
function saveQueue($queue)
{
file_put_contents(CACHE.'multipart_queue.txt',serialize($queue));
releaseQueue();
}
function waitForQueue()
{
while(file_exists(CACHE.'multipart.lock'));
}
function lockQueue()
{
file_put_contents(CACHE.'multipart.lock',time());
}
function releaseQueue()
{
unlink(CACHE.'multipart.lock');
}
function writeDebug($msg)
{
if(DEBUG)
file_put_contents('debug.txt',$msg.PHP_EOL.'===================='.PHP_EOL,FILE_APPEND);
}
?>