Re: [patch] add UUID to HTTP headers

2015-06-09 Thread Alexander Malysh
Hi Vladimir,

thanks for the patch! But  first thing would be to know, why it’s needed? For 
messages tracking purposes you can always
use dlr-url with your params/id.

Second thing: List *local_… is not a C-style and duplication of headers costs 
performance...

Alex

 Am 04.06.2015 um 10:36 schrieb Vladimir Laskov samflan...@gmail.com:
 
 
 
 Hello, guys
 
 please see and confirm patch
 patch description: add UUID HTTP herader like here
 
 ==
 Server: Kannel/1.4.4
 Date: Thu, 04 Jun 2015 08:15:28 GMT
 Content-Length: 24
 Content-type: text/html
 Pragma: no-cache
 Cache-Control: no-cache
 X-Kannel-UUID: 4d069003-e43f-426e-8a95-ba21cb71dca5
 ==
 
 
 
 diff --git a/gw/smsbox.c b/gw/smsbox.c
 index b62e62e..2e0faf4 100644
 --- a/gw/smsbox.c
 +++ b/gw/smsbox.c
 @@ -213,8 +213,12 @@ static void delayed_http_reply(Msg *msg)
  break;
  }
  
 -http_send_reply(client, status, sendsms_reply_hdrs, answer);
 +List *local_sendsms_reply_hdrs = 
 http_header_duplicate(sendsms_reply_hdrs);
 +http_header_add(local_sendsms_reply_hdrs, X-Kannel-UUID, 
 octstr_get_cstr(os));
 +
 +http_send_reply(client, status, local_sendsms_reply_hdrs, answer);
  
 +http_destroy_headers(local_sendsms_reply_hdrs);
  octstr_destroy(answer);
  octstr_destroy(os);
  }
 
 
 
 THX
 --
 Vladimir Laskov
 samflan...@gmail.com mailto:samflan...@gmail.com
 +79266285176
 



Re: Bug in admin interface for parameter remove-message

2015-06-09 Thread Alexander Malysh
Hi,

see comment in redmine and try to fix your URL.

Alex

 Am 28.05.2015 um 11:26 schrieb Kirti Mandwade kirti.mandw...@gmail.com:
 
 Hello,
 From the latest user guide 
 http://www.kannel.org/download/kannel-userguide-snapshot/userguide.html#AEN926
  
 http://www.kannel.org/download/kannel-userguide-snapshot/userguide.html#AEN926
 remove-message Removes the message with the give id (an UUID) from the local 
 storage
 subsystem.
 But this is not working.
 I need to remove specific message from kannel queue and i am testing it by 
 using fakesmsc.
 
 Here is my redmine link:
 https://redmine.kannel.org/issues/718 https://redmine.kannel.org/issues/718
 
 Thanks
 Kirti



Re: concurrency issue with http_close_all_ports

2015-06-09 Thread Alexander Malysh
Hi David,

thanks for pointing to this race condition!

I can easy reproduce it but I don’t think that your fix is the right one 
because it may
hung if client don’t read response or read it but very slow.

I have to think a little bit more how to fix it.

Alex

 Am 31.03.2015 um 11:49 schrieb David Schneider david.schnei...@dimoco.eu:
 
 Hello
 
 I found a concurrency issue with the latest http server implementation.
 
 I'm running test_http_server with multiple threads (-t 5). If I send a 
 request which is delayed by a sleep and in the mean time I'm calling 
 http://localhost:8080/quit; then the server crashes during http_send_reply 
 call due to already freed client-conn.
 
 Index: test/test_http_server.c
 ===
 --- test/test_http_server.c(Revision 5141)
 +++ test/test_http_server.c(working copy)
 @@ -237,6 +237,9 @@
 if (extra_headers != NULL)
 http_header_combine(resph, extra_headers);
 
 +if (run)
 +gwthread_sleep(5);
 +
 /* return response to client */
 http_send_reply(client, status, resph, reply_body);
 
 
 testing with:
 test/test_http_server -t 5 
 curl http://localhost:8080; 
 sleep 1
 curl http://localhost:8080/quit;
 
 I found a possible solution in http.c: port_remove
 
 Index: gwlib/http.c
 ===
 --- gwlib/http.c(Revision 5141)
 +++ gwlib/http.c(working copy)
 @@ -2097,8 +2097,14 @@
  */
 gwlist_lock(active_connections);
 l = gwlist_search_all(active_connections, port, port_match);
 -while(l != NULL  (client = gwlist_extract_first(l)) != NULL)
 +while(l != NULL  (client = gwlist_extract_first(l)) != NULL) {
 conn_unregister(client-conn);
 +while (client-state == request_is_being_handled) {
 +gwthread_sleep(0.1);
 +}
 +}
 gwlist_unlock(active_connections);
 gwlist_destroy(l, NULL);
 while((client = gwlist_search(active_connections, port, port_match)) != 
 NULL)
 
 
 What do you think about that solution?
 
 David
 
 PS: There is a typo in test_http_server help:
 Index: test/test_http_server.c
 ===
 --- test/test_http_server.c(Revision 5141)
 +++ test/test_http_server.c(working copy)
 @@ -288,7 +291,7 @@
 info(0, read HTTP headers from file 'filename' and add them to);
 info(0, the request for url 'url');
 info(0, specific URIs with special functions are:);
 -info(0,   /quite - shutdown the HTTP server);
 +info(0,   /quit - shutdown the HTTP server);
 info(0,   /whitelist - provides the -w whitelist as response);
 info(0,   /blacklist - provides the -b blacklist as response);
 info(0,   /save - save a HTTP POST request body to a file 
 /tmp/body.pid.n);
 
 




Re: How to remove messages from Kannel local subsystem using

2015-06-09 Thread Alexander Malysh
Hi,

sorry for delay, but I don;t see bug here because wrong url used:

 2) Does the remove-message option actually work for the admin interface as
 mentioned in the Kannel documentation
 http://www.kannel.org/download/kannel-userguide-snapshot/userguide.html#AEN9
 26
 I've followed the steps of Kirti and I also get
 http://127.0.0.1:13000/remove-message?id=UUID?password=
 Denied error.

? twice? replace second ? with  and try again

Alex


 Am 21.05.2015 um 23:24 schrieb hbil...@ecommunicate.biz:
 
 Hi Alex,
 
 1) Was code for this feature accepted and committed
 https://redmine.kannel.org/issues/567 ?
 
 Add a new command to the kannel admin interface to delete the queued
 messages for certain criteria, like for SMSC connection XX or for short code
  or move these messages to certain directory:
 
 kannel_admin/delete-queue?smsc=XX
 kannel_admin/delete-queue?short-code=YYY
 kannel_admin/move-queue?smsc=XXdestination=URL_ENCODE('/some_directory/move
 d/')
 
 2) Does the remove-message option actually work for the admin interface as
 mentioned in the Kannel documentation
 http://www.kannel.org/download/kannel-userguide-snapshot/userguide.html#AEN9
 26
 I've followed the steps of Kirti and I also get
 http://127.0.0.1:13000/remove-message?id=UUID?password=
 Denied error.
 
 But lynx -dump http://127.0.0.1:13000/store-status.xml?password=; works
 and gives me the UUIDs. Which means the password and admin interface is
 working. (I've used 13000 as the admin port.)
 
 Either the Kannel documentation is wrong or there is a bug in the code
 regarding remove-message.
 Removes the message with the give id (an UUID) from the local storage
 subsystem.
 
 thanks
 
 --
 
 Message: 
 Date: Mon, 18 May 2015 18:59:11 +0530
 From: Kirti Mandwade kirti.mandw...@gmail.com
 To: devel@kannel.org
 Subject: Fwd: How to remove messages from Kannel local subsystem using
   UUID
 Message-ID:
   CACz0=AgQDxMbYHOA0t+w5tYbVLNRP=p+p6m4pcq6p8zuxnz...@mail.gmail.com
 Content-Type: text/plain; charset=utf-8
 
 Hello,
 
 I need to remove specific message from kannel queue and i am testing it by
 using fakesmsc.
 
 So far what i did is:
 1) I used this command to check the status of various smsc.This works fine
 
 lynx -dump http://127.0.0.1:xxx/status?password=;
 
 2) I took down fakesmsc and sent 10 sms.
 
 3) I used the following command to check the queue.
 lynx -dump http://127.0.0.1:xxx/store-status.xml?password=;
 
 And got the following output
91fc3583-761a-4e1f-8493-3f47a01e628a MT-PUSH 2015-05-18 12:33:35
   1950 1876052832 fake1 dlrbox hello
   f8c68792-7d95-4d14-9a84-276a25aba8e4 MT-PUSH 2015-05-18 12:33:35
   1950 1126022293 fake1 dlrbox hello
   c9f5d10e-861d-48b4-a5ae-c6a743dcff21 MT-PUSH 2015-05-18 12:33:35
   1950 1638362136 fake1 dlrbox hello
   202f331a-6c5a-4120-a0de-f20bf71f1da9 MT-PUSH 2015-05-18 12:33:35
   1950 1903556200 fake1 dlrbox hello
   0924eb0d-7a98-4e58-9fbe-e549227f93f5 MT-PUSH 2015-05-18 12:33:35
   1950 1156234781 fake1 dlrbox hello
   a91495f9-f48f-4b2d-8c6b-3b3872bde40b MT-PUSH 2015-05-18 12:33:35
   1950 1039133110 fake1 dlrbox hello
   d5b14df4-2025-4176-97a6-d8f034d2c024 MT-PUSH 2015-05-18 12:33:35
   1950 1295345287 fake1 dlrbox hello
 
 
 
 4) I wanted to remove these messages from the queue using the UUID's. So i
 tried doing
 
 lynx -dump 
 http://127.0.0.1:13000/remove-message?id=91fc3583-761a-4e1f-8493-3f47a01e628
 a
 
 
 This gave me Denied error
 
 
 5) Then i tried removing using password
 http://127.0.0.1:13000/remove-message?id=91fc3583-761a-4e1f-8493-3f47a01e628
 a?password=
 
 
 Still it gave me error Denied.
 
 It should work as its given in Kannel svn-r5114 doc that we can use
 remove-message command for removing messages.
 
 remove-message - Removes the message with the give id (an UUID) from the
 local storage subsystem.
 Can someone explain me about how to make this to work.
 
 
 Also please check the following link.
 https://redmine.kannel.org/issues/567
 
 I want to know is this working i cant find any related documents. Its
 posted a long time ago so it should be implemented till now.
 
 Thanks
 Kirti
 
 




DLR-MO get queued on store until restart

2015-06-09 Thread José Héctor Galimberti
Hi im having this issue, im getting some DLR-MO queued on the store, and
they dont get out until i restart kannel.

My scenario:

I have two kannel boxes (tried svn-r5143M and 1.4.4, both giving me same
results)

From the point of view of the receiving DLRS i think this is the path:
CUSTOMER =(opensmppbox) KANNEL1 (smsc smpp) = (opensmppbox) KANNEL2
(smsbox http generic) = PHP

PHP inyecting DLR calling http://127.0.0.1:13015/sms?username=
http://127.0.0.1:13015/sms?username=password=dlr-mask=1dlr-mid=X
-XXX-X-X
password=dlr-mask=1dlr-mid=X-XXX-X-X

I put log level at 0 on everywere, do some wireshark traces also, and i
cannot figure out why im having this issue.

I have this example:


lynx -dump http://localhost:13000/store-status?password=XX;


SMS ID   Type   TimeSender
ReceiverSMSC ID BOX ID UDH Message
5168f8be-8f3b-45e5-9e23-5731f99e22c9 DLR-MO 2015-06-09 22:34:13 XX
+52 SMPPSMPP


cat /var/spool/kannel/75/5168f8be-8f3b-45e5-9e23-5731f99e22c9
S+52XUw°5SMPP$ae26e4cd-041d-4ee1-a884-435483caa6f7
1433907248$5168f8be-8f3b-45e5-9e23-5731f99e22c9$
ae26e4cd-041d-4ee1-a884-435483caa6f7SMPP


I ask the file for time:
ls --full-time ./75/5168f8be-8f3b-45e5-9e23-5731f99e22c9
-rw--- 1 kannel nogroup 275 2015-06-09 22:34:13.110916048 -0500
./75/5168f8be-8f3b-45e5-9e23-5731f99e22c

And search that time on the logs to see if i found something:

grep 22:34:13 /var/log/kannel/*.log

/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP[SMPP]:
Got request
`/sms?username=XXpassword=XXdlr-mask=1dlr-mid=ae26e4cd-041d-4ee1
-a884-435483caa6f7'
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP[SMPP]:
Received an HTTP request
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: DLR[mysql]:
Looking for DLR smsc=SMPP, ts=ae26e4cd-041d-4ee1-a884-435483caa6f7,
dst=(null), type=1
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: sql: SELECT
`mask`, `service`, `url`, `source`, `destination`, `boxc_id` FROM `dlr1`
WHERE `smsc`=? AND `ts`=?  LIMIT 1
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: column=mask
buffer_type=253 max_length=0 length=12
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG:
column=service buffer_type=253 max_length=0 length=48
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: column=url
buffer_type=253 max_length=0 length=6144
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG:
column=source buffer_type=253 max_length=0 length=96
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG:
column=destination buffer_type=253 max_length=0 length=96
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG:
column=boxc_id buffer_type=253 max_length=0 length=48
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: DLR[mysql]:
created DLR message for URL ae26e4cd-041d-4ee1-a884-435483caa6f7
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: removing DLR
from database
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: sql: DELETE
FROM `dlr1` WHERE `smsc`=? AND `ts`=?  LIMIT 1
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP[SMPP]:
Received DLR for DLR-URL ae26e4cd-041d-4ee1-a884-435483caa6f7
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP[SMPP]:
Sending reply
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP:
Resetting HTTPClient for `127.0.0.1'.
/var/log/kannel/http.log:2015-06-09 22:34:13 [5766] [11] DEBUG: HTTP[SMPP]:
Destroying client information

I see that generic HTTP succesfully receive the DLR

/var/log/kannel/kannel_access.log:2015-06-09 22:34:13 Receive DLR
[SMSC:SMPP] [SVC:1433907248] [ACT:] [BINF:]
[FID:ae26e4cd-041d-4ee1-a884-435483caa6f7] [META:] [from:XXX]
[to:+52X] [flags:-1:-1:-1:-1:1] [msg:0:] [udh:0:]

I see DLR on this too...

/var/log/kannel/kannel.log:2015-06-09 22:34:13 [5766] [2] DEBUG: HTTP:
Creating HTTPClient for `127.0.0.1'.
/var/log/kannel/kannel.log:2015-06-09 22:34:13 [5766] [2] DEBUG: HTTP:
Created HTTPClient area 0x24eadd0.
/var/log/kannel/kannel.log:2015-06-09 22:34:13 [5766] [10] DEBUG: HTTP:
Destroying HTTPClient area 0x24eadd0.
/var/log/kannel/kannel.log:2015-06-09 22:34:13 [5766] [10] DEBUG: HTTP:
Destroying HTTPClient for `127.0.0.1'.

This doesnt tells me much more

More than ten minutes latter and after doing the restart opensmppbox seems
to send the DLR-MO:

grep ae26e4cd-041d-4ee1-a884-435483caa6f7 /var/log/kannel/opensmppbox.log

/var/log/kannel/opensmppbox.log:2015-06-09 22:48:54 [25816] [1] DEBUG:
DLR[mysql]: Looking for DLR smsc=SMPP,
ts=ae26e4cd-041d-4ee1-a884-435483caa6f7, dst=+52XXX, type=1
/var/log/kannel/opensmppbox.log:2015-06-09 22:48:54 [25816] [1] DEBUG:
DLR[mysql]: created DLR message for URL