Re: HTTP implementation/usage problems (sendsms)

Navjot Singh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Net4India Ltd.
Message-ID <[email protected]>
are you closing the streams properly?

navjot

Oscar Medina Duarte wrote:

>Hi all !
>
>I'm not sure yet if I'm doing something wrong, but I think we may have a
>bug on http implementation, but is hard to explain, so please be
>patient.
>
>What am I doing?
>I'm sending a sms request (MO) to a servlet, the servlet should reply
>using the sendsms http interface, that is requesting a url like:
>
>http://localhost:8080/kannel_test/KannelTest?from=222140576&to=4378&keyWord=ll9f&scndWord=segunda&theRest=todo%20lo%20demas
>
>The related confs:
>
>group = smsbox
>bearerbox-host = localhost
>sendsms-port = 64235
>global-sender = 4378
>reply-couldnotfetch = "Contacta a soporte code 1"
>reply-couldnotrepresent = "Contacta a soporte code 2"
>reply-requestfailed = "Contacta a soporte code 3"
>reply-emptymessage = "Contacta a soporte code 4"
>
>group = sms-service
>keyword = default
>post-url =
>"http://localhost:8080/kannel_test/KannelTest?from=%p&to=%P&keyWord=%k&scndWord=%s&theRest=%r"
>#accept-x-kannel-headers = true
>max-messages = 0
>
>
>What is the problem?
>The problem is that when my java app tries to get the URL, I get an
>exception like:
>
>java.net.SocketException: Unexpected end of file from server
>
>in the JVM, and the debug on smsbox looks like:
>
>2004-08-12 18:30:49 [13488] [2] DEBUG: HTTP: Creating HTTPClient for
>`127.0.0.1'.
>2004-08-12 18:30:49 [13488] [1] DEBUG: HTTP: Destroying HTTPClient area
>0x941f2c8.
>2004-08-12 18:30:49 [13488] [1] DEBUG: HTTP: Destroying HTTPClient for
>`127.0.0.1'.
>2004-08-12 18:30:49 [13488] [2] DEBUG: HTTP: Creating HTTPClient for
>`127.0.0.1'.
>2004-08-12 18:30:49 [13488] [1] DEBUG: HTTP: Destroying HTTPClient area
>0x941f2c8.
>2004-08-12 18:30:49 [13488] [1] DEBUG: HTTP: Destroying HTTPClient for
>`127.0.0.1'.
>
>Ok, that looks like a problem at my java app, so I tried connecting to
>another url with my app with no problem, thats why I partially discarded
>that possibility.
>
>The next thing that may had gone wrong was the URL creation, so I tried
>with Mozilla using the url generated by my app, and it worked fine.
>
>So, I decided to sniff and compare 3 tests:
>
>1.- My App connecting to www.google.com :
>
>My app sent this:
>
>GET / HTTP/1.1
>User-Agent: Java/1.4.2_03
>Host: www.google.com
>Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>Connection: keep-alive
>
>and received this from google:
>
>HTTP/1.1 302 Found
>Location:
>http://www.google.com.mx/cxfer?c=PREF%3D:TM%3D1092355048:S%3DKFxs1Ocs1_d6SPlR
>Set-Cookie:
>PREF=ID=7296c503648eed6e:CR=1:TM=1092355048:LM=1092355048:S=_Z4iNjWgx73z9Dz1; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
>Content-Type: text/html
>Server: GWS/2.1
>Content-Length: 207
>Date: Thu, 12 Aug 2004 23:57:28 GMT
>
><HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY>
><H1>302 Moved</H1>
>The document has moved
><A
>HREF="http://www.google.com.mx/cxfer?c=PREF%3D:TM%3D1092355048:S%3DKFxs1Ocs1_d6SPlR">here</A>.
></BODY></HTML>
>
>No exceptions thrown, and sniffing seems quite ok to me.
>
>2.- Mozilla connecting to the URL created by my app:
>
>Mozila said:
>
>GET
>/cgi-bin/sendsms?username=xxx&password=xxx&to=2221401576&from=4378&text=mensaje HTTP/1.1
>Host: localhost:64235
>User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
>Gecko/20031030
>Accept:
>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
>Accept-Language: en-us,en;q=0.5
>Accept-Encoding: gzip,deflate
>Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
>Keep-Alive: 300
>Connection: keep-alive
>
>
>Kannel responded:
>
>HTTP/1.1 202 Accepted
>Server: Kannel/cvs-20040812
>Content-Length: 5
>Content-type: text/html
>Pragma: no-cache
>Cache-Control: no-cache
>
>Sent.
>
>And everything worked smoothly.
>
>
>3.- My App sending via Kannel :
>
>My app said:
>
>GET
>/cgi-bin/sendsms?username=xxx&password=xxx&to=2221401576&from=4378&text=mensaje via http request HTTP/1.1
>User-Agent: Java/1.4.2_03
>Host: localhost:64235
>Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>Connection: keep-alive
>
>
>
>And Kannel had nothing to say... Exception was thrown and the problem I
>explained before.
>
>Flags at TCP level :
>
>myApp [SYN]
>Kannel [SYN, ACK]
>
>myApp [ACK]
>myApp [PSH, ACK] Here goes the HTTP request
>
>{
>	Kannel [ACK]
>	Kannel [FIN, ACK]
>
>instead of:
>	Kannel [ACK]
>	Kannel [PSH, ACK] HTTP response from kannel
>
>}
>...
>
>
>I'm not very http literate, but I see no reason for kannel to reject my
>connection from my java app, there are some obvious differences from the
>Mozilla version of the request to java's request, but, should that be an
>issue for Kannel?
>
>BTW: the piece of code I'm connecting with at my java app is :
>
>... some code ...
>// At this point sb.toString returns the full URL to connect to
> url = new URL(sb.toString());
>		
>// The exception is thrown at this line, at the URL.openStream() method.
> br = new BufferedReader(new InputStreamReader(url.openStream()));
>... some code ...
>
>Thanks for the patience on reading this looong e-mail, and please tell
>me what do you think about it, or if someone know a better way of doing
>that in java, I will appreciate it!!
>
>P.S. also tell me if I'm missing some info to post.
>
>== Oscar
>OM MANI PEME HUM 
>
>
>
>.
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.