RE: Sending post request in java
Try to disable keep alive connections (if those are being used). Rene Kluwen Chimit -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Gelvis SequeraSent: dinsdag 20 september 2005 21:56To: users@kannel.orgSubject: Sending post request in java Hi. I'm triying to send to consecutive messages from kannel using the Java HttpUrlConnection, but after I send the first, the smsbox dies (but the bearebox keeps up). My conf file is group = smscsmsc = atmodemtype = wavecomdevice = /dev/ttyS1pin = 1286sim-buffering = truespeed = 115200my-number = +58412*** group = smsboxbearerbox-host = localhostsendsms-port = 13013log-file = "/var/log/kannel/smsbox.log"log-level = 0access-log = "/var/log/kannel/access.log"immediate-sendsms-reply = true group = modemsid = wavecomname = Wavecomdetect-string = "WAVECOM MODEM"#broken = truemessage-storage = SMenable-mms = trueinit-string = "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0" need-sleep = true And my log is 2005-09-20 11:05:18 [11434] [3] INFO: sendsms sender: (192.168.1.86) to: msg: 2005-09-20 11:05:18 [11434] [3] DEBUG: message length 68, sending 1 messages2005-09-20 11:05:18 [11434] [3] DEBUG: Status: 202 Answer: 2005-09-20 11:05:18 [11434] [3] DEBUG: HTTP: Resetting HTTPClient for `192.168.1.86'. 2005-09-20 11:05:18 [11434] [3] PANIC: gwlib/octstr.c:2355: seems_valid_real: Assertion `ostr->data != NULL' failed. (Called from gwlib/octstr.c:317:octstr_destroy.)2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(gw_panic+0x19a) [0x808015b] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8086fa2]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(octstr_destroy+0x2f) [0x8081641]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x805af7d] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8075dae]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] My post request is something like this: +5841** MESSAGE * * Any Ideas???
Re: Sending post request in java
The keep alive option is disable, but the problem still happens, but now the log changed to: 2005-09-21 08:57:42 [16586] [3] DEBUG: HTTP: Resetting HTTPClient for `192.168.1.81'.2005-09-21 08:57:42 [16586] [3] PANIC: gwlib/octstr.c:2343: seems_valid_real: Assertion `ostr->len >= 0' failed. (Called from gwlib/octstr.c:317:octstr_destroy.) 2005-09-21 08:57:42 [16586] [3] PANIC: /usr/local/sbin/smsbox(gw_panic+0x19a) [0x808015b]2005-09-21 08:57:42 [16584] [1] DEBUG: HTTP: Destroying HTTPClient area 0x814fe30.2005-09-21 08:57:42 [16584] [1] DEBUG: HTTP: Destroying HTTPClient for `192.168.1.81'. 2005-09-21 08:57:42 [16586] [3] PANIC: /usr/local/sbin/smsbox [0x8086dee]2005-09-21 08:57:42 [16586] [3] PANIC: /usr/local/sbin/smsbox(octstr_destroy+0x2f) [0x8081641]2005-09-21 08:57:42 [16586] [3] PANIC: /usr/local/sbin/smsbox [0x805af7d] 2005-09-21 08:57:42 [16586] [3] PANIC: /usr/local/sbin/smsbox [0x8075dae]2005-09-21 08:57:42 [16586] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-21 08:57:42 [16586] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] It looks like the gateway tries to free a memory spaced that already been deleted On 9/20/05, Rene Kluwen <[EMAIL PROTECTED]> wrote: Try to disable keep alive connections (if those are being used). Rene Kluwen Chimit -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Gelvis SequeraSent: dinsdag 20 september 2005 21:56 To: users@kannel.orgSubject: Sending post request in java Hi. I'm triying to send to consecutive messages from kannel using the Java HttpUrlConnection, but after I send the first, the smsbox dies (but the bearebox keeps up). My conf file is group = smscsmsc = atmodemtype = wavecomdevice = /dev/ttyS1pin = 1286sim-buffering = truespeed = 115200my-number = +58412*** group = smsboxbearerbox-host = localhostsendsms-port = 13013log-file = "/var/log/kannel/smsbox.log"log-level = 0access-log = "/var/log/kannel/access.log"immediate-sendsms-reply = true group = modemsid = wavecomname = Wavecomdetect-string = "WAVECOM MODEM"#broken = truemessage-storage = SMenable-mms = trueinit-string = "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0" need-sleep = true And my log is 2005-09-20 11:05:18 [11434] [3] INFO: sendsms sender: (192.168.1.86) to: msg: 2005-09-20 11:05:18 [11434] [3] DEBUG: message length 68, sending 1 messages2005-09-20 11:05:18 [11434] [3] DEBUG: Status: 202 Answer: 2005-09-20 11:05:18 [11434] [3] DEBUG: HTTP: Resetting HTTPClient for `192.168.1.86'. 2005-09-20 11:05:18 [11434] [3] PANIC: gwlib/octstr.c:2355: seems_valid_real: Assertion `ostr->data != NULL' failed. (Called from gwlib/octstr.c:317:octstr_destroy.)2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(gw_panic+0x19a) [0x808015b] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8086fa2]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(octstr_destroy+0x2f) [0x8081641]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x805af7d] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8075dae]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] My post request is something like this: +5841** MESSAGE * * Any Ideas???
Re: Sending post request in java
compile with export CFLAGS="-ggdb -rdynamic -O0" to get the full stack trace, so we can give you more information. Wilfried Goesgens
RE: Sending post request in java
I had the same problems trying to send Push Mesages from Java using the HttpUrlConnection. Checking with Ethereal I found out that the HttpUrlConnection object breaks the request into two packets and that probably confuses Kannel. I tried using sockets (more work of course) and everything worked well. Also the HttpClient library from Apache Commons works well with kannel and is much easier to use than HttpUrlConnection. Just don't use the HttpUrlConnection object. Good luck! Spyros Sakellariou -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Gelvis SequeraSent: Tuesday, September 20, 2005 10:56 PMTo: users@kannel.orgSubject: Sending post request in java Hi. I'm triying to send to consecutive messages from kannel using the Java HttpUrlConnection, but after I send the first, the smsbox dies (but the bearebox keeps up). My conf file is group = smscsmsc = atmodemtype = wavecomdevice = /dev/ttyS1pin = 1286sim-buffering = truespeed = 115200my-number = +58412*** group = smsboxbearerbox-host = localhostsendsms-port = 13013log-file = "/var/log/kannel/smsbox.log"log-level = 0access-log = "/var/log/kannel/access.log"immediate-sendsms-reply = true group = modemsid = wavecomname = Wavecomdetect-string = "WAVECOM MODEM"#broken = truemessage-storage = SMenable-mms = trueinit-string = "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0" need-sleep = true And my log is 2005-09-20 11:05:18 [11434] [3] INFO: sendsms sender: (192.168.1.86) to: msg: 2005-09-20 11:05:18 [11434] [3] DEBUG: message length 68, sending 1 messages2005-09-20 11:05:18 [11434] [3] DEBUG: Status: 202 Answer: 2005-09-20 11:05:18 [11434] [3] DEBUG: HTTP: Resetting HTTPClient for `192.168.1.86'. 2005-09-20 11:05:18 [11434] [3] PANIC: gwlib/octstr.c:2355: seems_valid_real: Assertion `ostr->data != NULL' failed. (Called from gwlib/octstr.c:317:octstr_destroy.)2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(gw_panic+0x19a) [0x808015b] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8086fa2]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(octstr_destroy+0x2f) [0x8081641]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x805af7d] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8075dae]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] My post request is something like this: +5841** MESSAGE * * Any Ideas???
Re: Sending post request in java
I used the HttpCLient, and i couldn't resolve the problem here is a piece of code: case Request.POST: methodP = new PostMethod(url); methodP.setRequestHeader("Content-type", "text/xml"); methodP.setRequestBody(request.getRequest()); client.executeMethod(methodP); response = methodP.getResponseBodyAsString(); break; do i have to set some attribute on the PostMethod is there any tip? Thanks .. On 9/22/05, Spyros Sakellariou <[EMAIL PROTECTED]> wrote: I had the same problems trying to send Push Mesages from Java using the HttpUrlConnection. Checking with Ethereal I found out that the HttpUrlConnection object breaks the request into two packets and that probably confuses Kannel. I tried using sockets (more work of course) and everything worked well. Also the HttpClient library from Apache Commons works well with kannel and is much easier to use than HttpUrlConnection. Just don't use the HttpUrlConnection object. Good luck! Spyros Sakellariou -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Gelvis Sequera Sent: Tuesday, September 20, 2005 10:56 PMTo: users@kannel.orgSubject: Sending post request in java Hi. I'm triying to send to consecutive messages from kannel using the Java HttpUrlConnection, but after I send the first, the smsbox dies (but the bearebox keeps up). My conf file is group = smscsmsc = atmodemtype = wavecomdevice = /dev/ttyS1pin = 1286sim-buffering = truespeed = 115200my-number = +58412*** group = smsboxbearerbox-host = localhostsendsms-port = 13013log-file = "/var/log/kannel/smsbox.log"log-level = 0access-log = "/var/log/kannel/access.log"immediate-sendsms-reply = true group = modemsid = wavecomname = Wavecomdetect-string = "WAVECOM MODEM"#broken = truemessage-storage = SMenable-mms = trueinit-string = "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0" need-sleep = true And my log is 2005-09-20 11:05:18 [11434] [3] INFO: sendsms sender: (192.168.1.86) to: msg: 2005-09-20 11:05:18 [11434] [3] DEBUG: message length 68, sending 1 messages2005-09-20 11:05:18 [11434] [3] DEBUG: Status: 202 Answer: 2005-09-20 11:05:18 [11434] [3] DEBUG: HTTP: Resetting HTTPClient for `192.168.1.86'. 2005-09-20 11:05:18 [11434] [3] PANIC: gwlib/octstr.c:2355: seems_valid_real: Assertion `ostr->data != NULL' failed. (Called from gwlib/octstr.c:317:octstr_destroy.)2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(gw_panic+0x19a) [0x808015b] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8086fa2]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox(octstr_destroy+0x2f) [0x8081641]2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x805af7d] 2005-09-20 11:05:18 [11434] [3] PANIC: /usr/local/sbin/smsbox [0x8075dae]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-20 11:05:18 [11434] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] My post request is something like this: +5841** MESSAGE * * Any Ideas???
RE: Sending post request in java
Well although I have never tested my client for SMS but for Push Proxy, one difference that I see with my code (using Sockets but the principle is the same) is the "Content-Type" parameter. Try setting it to "application/xml" instead of "text/xml" One more problem that I had is that all new lines have to end with \r\n and not just \n or \r If all else fails you will need to use Ethereal (it is open source and you can get it from http://www.ethereal.com/) to make sure that the Content-Length of your post request is absolutely correct. Kannel is very sensitive to wrong content lengths. Here is some code that succesfully sends a POST request to kannel WAP Push. I think that if you change the code to your needs you should make it work for SMS as well (sorry is in sockets not HttpClient - can't seem to find any old code with HttpClient :( === import java.net.*;import java.io.*;/* * PushMeSocket.java * */ public class PushMeSocket { URL PPGurl; String PPG_URL; String charen = "UTF-8"; String hostName = "is-3052"; int port = 39898; String path = "/wappush"; InetAddress inetAddress; Socket socket; String data; /** Creates a new instance of PushMeSocket */ public PushMeSocket() { this.PPG_URL = "http://is-3052:39898/wappush"; try { inetAddress = InetAddress.getByName(hostName); socket = new Socket(inetAddress,port); } catch (Exception e) { e.printStackTrace(); } } /** * @param args the command line arguments */ public static void main(String[] args) { PushMeSocket push = new PushMeSocket(); StringBuffer xmlBuffer = new StringBuffer(); char tmp; int readTmp; try { BufferedReader xmlFile = new BufferedReader(new FileReader(args[0])); while ((readTmp=(char)xmlFile.read())!=65535){ tmp = (char) readTmp; if (readTmp == 10) { xmlBuffer.append('\r'); } xmlBuffer.append(tmp); } xmlFile.close(); push.data = ""> } catch (Exception e) { e.printStackTrace(); } System.out.println(push.PushMessage(push.data, "multipartboundary")); } public String PushMessage(String XMLDoc, String MultiPartSeperator) { StringBuffer replyString = new StringBuffer(); StringBuffer headerString = new StringBuffer(); try { BufferedWriter sendXMLStream = new BufferedWriter (new OutputStreamWriter(socket.getOutputStream(),this.charen)); BufferedReader ppgReply = new BufferedReader(new InputStreamReader(socket.getInputStream(),this.charen)); headerString.append("POST " + this.path + " HTTP/1.1\r\n"); headerString.append("Host: " + this.hostName + ":"+this.port+"\r\n"); headerString.append("Content-Type: multipart/related; boundary="+MultiPartSeperator+"; type=\"application/xml\"\r\n"); headerString.append("Content-Length: " + (XMLDoc.getBytes().length) +"\r\n\r\n"); sendXMLStream.write(headerString.toString()); sendXMLStream.write(XMLDoc); System.out.println("+"); System.out.println(headerString.toString()); System.out.println(XMLDoc); System.out.println("+"); sendXMLStream.flush(); char[] tmp = new char[5000]; System.out.println("Ready to receive reply "); ppgReply.read(tmp); replyString.append(tmp); ppgReply.close(); sendXMLStream.close(); } catch (Exception e) { e.printStackTrace(); } return replyString.toString(); } }============= Hope it helps, Spyros -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Gelvis SequeraSent: Thursday, September 22, 2005 6:21 PMTo: users@kannel.orgSubject: Re: Sending post
Re: Sending post request in java
On Thu, Sep 22, 2005 at 01:51:30PM +0300, Spyros Sakellariou wrote: >breaks the request into two packets and that probably confuses Kannel. as of both, kannel and your java programm use the kernel tcp/ip stack this is most likely not the case. It is the content wich you should have a look at. Capture it using netcat as server instead ov kannel, and use netcat afterwards to test kannel. please recompile kannel with the flags I gave you, and post the complete Panic stack trace again. Wilfried Goesgens
RE: Sending post request in java
Well Ethereal shows two packets when I use the HttpUrlConnection object and only one when I use java sockets or other utility objects such as the apache commons client. The problem was fixed when I used sockets. So what I am saying is that probably this is not a Kannel problem but a Java problem, since the way to fix it for me was to stay away from the HttpUrlConnection object. I posted some Java code before that it worked for me for sending Push requests to kannel so I think with a few modifications Gelvis can use it for sendind SMS requests as well. I experienced the same problems he describes when I used the HttpUrlConnection object. Spyros -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Wilfried Goesgens Sent: Friday, September 23, 2005 11:24 AM To: users@kannel.org Subject: Re: Sending post request in java On Thu, Sep 22, 2005 at 01:51:30PM +0300, Spyros Sakellariou wrote: >breaks the request into two packets and that probably confuses Kannel. as of both, kannel and your java programm use the kernel tcp/ip stack this is most likely not the case. It is the content wich you should have a look at. Capture it using netcat as server instead ov kannel, and use netcat afterwards to test kannel. please recompile kannel with the flags I gave you, and post the complete Panic stack trace again. Wilfried Goesgens
Re: Sending post request in java
After recompiling the CVS source with the flags that you comment me. I used netcat to catch the following post request (the request tries to send the same message to 2 users) POST /cgi-bin/sendsms HTTP/1.1Content-Type: text/xmlConnection: Keep-AliveUser-Agent: Jakarta Commons-HttpClient/2.0.2Host: 192.168.1.145:13013Content-Length: 182 +584167276448+584127239834Texto del mensajetestcoquimbo And the answer with the inmediate-reply=true is HTTP/1.1 202 AcceptedServer: Kannel/cvs-20050919Content-Length: 52Content-type: text/htmlPragma: no-cacheCache-Control: no-cache HTTP/1.1 202 AcceptedServer: Kannel/cvs-20050919Content-Length: 52Content-type: text/htmlPragma: no-cacheCache-Control: no-cache and with false it hangs waiting for the second message send (that doesn't occurs). The smsbox.log with full panic when the inmediate reply is true is: 2005-09-23 11:09:40 [17504] [2] DEBUG: HTTP: Creating HTTPClient for `127.0.0.1'.2005-09-23 11:09:40 [17504] [2] DEBUG: HTTP: Created HTTPClient area 0x814fe30.2005-09-23 11:09:42 [17505] [3] INFO: smsbox: Got HTTP request from < 127.0.0.1>2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: XML: <+584167276448+584127239834 2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value <+584167276448+584127239834> 2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value <+584167276448>2005-09-23 11:09:42 [17505] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:09:42 [17505] [3] INFO: sendsms used by 2005-09-23 11:09:42 [17505] [3] INFO: sendsms sender: (127.0.0.1) to: msg:2005-09-23 11:09:42 [17505] [3] DEBUG: message length 17, sending 1 messages 2005-09-23 11:09:42 [17505] [3] DEBUG: Status: 202 Answer: 2005-09-23 11:09:42 [17505] [3] DEBUG: HTTP: Resetting HTTPClient for `127.0.0.1'.2005-09-23 11:09:42 [17505] [3] PANIC: gwlib/octstr.c:2355: seems_valid_real: Assertion `ostr->data != NULL' failed. (Called from gwlib/octs) 2005-09-23 11:09:42 [17505] [3] PANIC: ./smsbox(gw_panic+0x19a) [0x808015b]2005-09-23 11:09:42 [17505] [3] PANIC: ./smsbox [0x8086fa2]2005-09-23 11:09:42 [17505] [3] PANIC: ./smsbox(octstr_destroy+0x2f) [0x8081641] 2005-09-23 11:09:42 [17505] [3] PANIC: ./smsbox [0x805af7d]2005-09-23 11:09:42 [17505] [3] PANIC: ./smsbox [0x8075dae]2005-09-23 11:09:42 [17505] [3] PANIC: /lib/libpthread.so.0 [0xb7f0b2fe]2005-09-23 11:09:42 [17505] [3] PANIC: /lib/libc.so.6(__clone+0x5a) [0xb7cb4ada] but if the inmediate-reply is false, the log is 2005-09-23 11:15:03 [17529] [2] DEBUG: HTTP: Creating HTTPClient for `127.0.0.1'.2005-09-23 11:15:03 [17529] [2] DEBUG: HTTP: Created HTTPClient area 0x814fe30.2005-09-23 11:15:14 [17530] [3] INFO: smsbox: Got HTTP request from < 127.0.0.1>2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: XML: <+584167276448+584127239834Texto del mensajetestcoquimbo> 2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value <+584167276448+584127239834> 2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value <+584167276448>2005-09-23 11:15:14 [17530] [3] DEBUG: XMLParsing: tag value 2005-09-23 11:15:14 [17530] [3] INFO: sendsms used by 2005-09-23 11:15:14 [17530] [3] INFO: sendsms sender: (127.0.0.1) to: msg:2005-09-23 11:15:14 [17530] [3] DEBUG: message length 17, sending 1 messages 2005-09-23 11:15:14 [17530] [3] DEBUG: Stored UUID 446c0b51-c4a0-48a3-8654-00d5a6d9262e2005-09-23 11:15:14 [17530] [3] DEBUG: Status: 202 Answer: 2005-09-23 11:15:14 [17530] [3] DEBUG: Delayed reply - wait for bearerbox 2005-09-23 11:15:14 [17526] [0] DEBUG: Got ACK (0) of 446c0b51-c4a0-48a3-8654-00d5a6d9262e2005-09-23 11:15:14 [17526] [0] DEBUG: No client - multi-send or ACK to pull-reply I'm clueless for the reason that kannel doesn't send the second message and hangs. The funny part of all is that you do the same thing, but instead of using a POST method, use a GET method, kannel sends both messages, but don't return anything. Gelvis