kneodev / ksmppd

Kurt's SMPP Daemon (SMPP Server for Kannel)
Other
57 stars 39 forks source link

Problem sending back message from gateway to SMPP Client #160

Open lmv2022 opened 1 year ago

lmv2022 commented 1 year ago

First at all, apologies if this topic is repeated, but i have issues with routing behaviuor using ksmppd ( kannel smpp server ) and i do not know if this happens due to a config error or for a missunderstanding about how this application works.

I have the following situation

SMPP Client <=> KSMPPD <=> Bearerbox1

The SMPP client bind to KSMPPD with user smpptest2 port 57005. The bearerbox binds to KSMPPD with user smpptest port 57005.

My config files are

ksmppd.con

group=ksmppd
log-file=/var/log/smppd/smppdtest.log
log-level=0
smpp-port=57005
database-type=mysql
database-config=cfgsmpp
database-enable-queue=1
id=KANNELSMPP
inbound-queue-threads=4
outbound-queue-threads=4
auth-method=1

group=mysql-connection
id=cfgsmpp
host=localhost
username=smppsvr
password=smppsvr
database=smpp_server_test
max-connections=5

group=bearerbox-connection
id=KSMPPD
host=localhost
port=57001

group=http-server
port=57015
password=ksmppdpass

group=smpp-routing
routing-method=1

bearerbox.conf

group = core
admin-port = 57000
smsbox-port = 57001
admin-password = bar
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
log-file = "/var/log/kannel/bearerboxsmppserver_test.log"
#dlr-storage = internal

group = smsc
smsc = smpp
smsc-id = smsc_conn_1
host = localhost
port = 57005
#receive-port = 57005
transceiver-mode = true
smsc-username = "smpptest"
smsc-password = "smpptest"
system-type = "SMPP"
source-addr-ton = 2
source-addr-npi = 1
dest-addr-ton = 1
dest-addr-npi = 1
address-range = ""
alt-charset = "ASCII"
reroute = true
reroute-dlr = true
allowed-smsc-id= smsc_conn_1

group = smsbox
smsbox-id = smsbox_conn_1
bearerbox-host = localhost
sendsms-port = 57003
global-sender = 57003
log-file = "/var/log/kannel/smsboxsmppserver_test.log"
log-level = 0
access-log = "/var/log/kannel/accessboxsmppserver_test.log"

group = sendsms-user
username = smppsrv
password = smppsrv
max-messages = 5
concatenation = 1

group = sms-service
keyword = default
get-url = "http://localhost/test.php/SMSRx.php?operator=test&user=%P&movil=%p&msg=%a&timestamp=%t"
max-messages=3
concatenation=true

In my database table smpp-route i have the following

+----------+-----------+-------+------+-----------+-------------+--------------+----------+
| route_id | direction | regex | cost | system_id | smsc_id     | source_regex | priority |
+----------+-----------+-------+------+-----------+-------------+--------------+----------+
|        1 |         1 |       | NULL | smpptest2 | smsc_conn_1 |              |        0 |
+----------+-----------+-------+------+-----------+-------------+--------------+----------+

When the SMPP Client send a message to KSMPPD ( submit_sm ) I have two scenarios If allowed-smsc-id is not set the KSMPPD route the message to smsc_conn_1 and got a submit_sm_resp with status 0x00000045. The SMPP client received this status too.

If allowed-smsc-id is set with value "smsc_conn_1" the KSMPPD route succesfully the sms to smsc_conn_1 and got a submit_sm_resp with status 0x00000000. This status is sent it back to the SMPP client. So for the client the message was successfully sent. But later the message is received again in KSMPPD, this time from Bearerbox1, and then KSMPPD sends it again to smsc_conn_1, but this time gets a submit_sm_resp whit status 0x0000000b (Invalid Destination Address). I suppose that this is because dont have a route entry in my table for user smpptest, so may be it is fine. But i do not understand why the config is in loop and how can i avoid this loop.

For a second test i've added a http type smsc

group = smsc
smsc = http
smsc-id = http_connection_1
system-type = kannel
smsc-username = smpptest
smsc-password = smpptest
port = 57020
send-url = "http://localhost/test_route.php"

and changed my smpp-route table like this

+----------+-----------+-------+------+-----------+-------------------+--------------+----------+
| route_id | direction | regex | cost | system_id | smsc_id           | source_regex | priority |
+----------+-----------+-------+------+-----------+-------------------+--------------+----------+
|        1 |         1 |       | NULL | smpptest2 | http_connection_1 |              |        0 |
+----------+-----------+-------+------+-----------+-------------------+--------------+----------+

This time the message from the SMPP client is routed succesfully towards the KSMPPD and Bearerbox1 and then the php script ( send-url ) is called.

So far this works ok

But now i want to send back a message from Bearerbox1 to SMPP CLient trough KSMPPD. This is in order to send deliver_sm messages like DRL or MT.

This direction of flow Bearerbox1 => KSMPPD => SMPP Client

I've tried many different configurations according to many closed answers found on web forums. Most of these points to a routing throught bearerbox , but nothing works in my case.

I tried to send a sms calling the kannel's url

curl "http://localhost:57003/cgi-bin/sendsms?username=smppsrv&password=smppsrv&from=2345&to=56998819005&text=test+back"

but the message, instead of travel throught the bearerbox1 to SMPP CLient, goes to smsc http_connection_1 and calls the php script. So nothing is seeing in the KSMPPD´s log and the SMPP client does not receive the message.

I added a new entry in the database

+----------+-----------+-------+------+-----------+-------------------+--------------+----------+
| route_id | direction | regex | cost | system_id | smsc_id           | source_regex | priority |
+----------+-----------+-------+------+-----------+-------------------+--------------+----------+
|        1 |         1 |       | NULL | smpptest2 | http_connection_1 |              |        0 |
|        2 |         2 |       | NULL | smpptest2 | smsc_conn_1       |              |        0 |
+----------+-----------+-------+------+-----------+-------------------+--------------+----------+

and the situation is the same

Tried with other option
+----------+-----------+-------+------+-----------+-------------------+--------------+----------+ | route_id | direction | regex | cost | system_id | smsc_id | source_regex | priority | +----------+-----------+-------+------+-----------+-------------------+--------------+----------+ | 1 | 1 | | NULL | smpptest2 | http_connection_1 | | 0 | | 2 | 2 | | NULL | smpptest2 | http_connection_1 | | 0 | +----------+-----------+-------+------+-----------+-------------------+--------------+----------+

same result.

If I try to send through the port 57020 , because i read that this is the port to send DLR responses, got the error

WARNING: smsbox_list empty!

Other attempts made was add params to SMS definitions like

reroute = true reroute-dlr = true

but nothing resolves the issue.

Could someone help me by telling me what I am doing wrong? or simply the kannel smpp server doesn't work like that.

Thanks in advance

akekoagba commented 1 year ago

From your bearerbox smsc-smpp configuration, you are looping back the MT to the ksmpp server. The smsc in the bearerbox should be terminating your MT from your ksmpdd clients. It should be an external smsc (not on localhost unless you configure fake smsc or have another smpp server on the localhost or you want to loopback to another user on the ksmppd).

lmv2022 commented 1 year ago

thanks for your reply. I will try to setup an additional smpp server. I think that will only pass the issue to the second server. Is it possible to avoid this and use only the smsbox configured in port 57003 ? It seems ilogical to must have to configure another kannel only to route outgoing messages to the smpp client ) like DLRs .