-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Terrence,

On 9/6/16 10:00 AM, Terence M. Bandoian wrote:
> On 9/5/2016 8:09 AM, Klemens Muthmann wrote:
>> Am 05.09.2016 um 14:49 schrieb Tim Watts:
>>> On Mon, 2016-09-05 at 14:11 +0200, Klemens Muthmann wrote:
>>>> Hi,
>>>> 
>>>> I currently need to implement an HTTP data transmission from
>>>> an Arduino with WiFi module to a PC running a Tomcat 8.5.4
>>>> instance. The Tomcat is running under Ubuntu 16.04.
>>>> 
>>>> The problem is that, since there are no HTTP libraries on
>>>> Arduino, I need to write the correct HTTP request myself and
>>>> I got stuck. It would be great if someone on the list with a
>>>> deeper understanding of the HTTP protocol would be willing to
>>>> support me. The transmitted (possibly erroneous ) request
>>>> looks like:
>>>> 
>>>> ======================================== GET
>>>> /push?VIN=testrun HTTP/1.1 User-Agent: Freematics Connection:
>>>> keep-alive Host:
>>>> 
>>>> ======================================== The server runs
>>>> under a local access point IP (10.42.0.1) and receives that
>>>> request correctly but throws me an EOFException from the
>>>> following code fragment:
>>>> 
>>>> nRead = channel.read(socketBufferHandler.getReadBuffer()); if
>>>> (nRead == -1) { throw new EOFException(); }
>>>> 
>>>> So it seems to me that an end of file is reached before it is
>>>> expected. Can somebody provide me with hints on how to solve
>>>> that issue and formulate a correct HTTP request to my Tomcat
>>>> instance?
>>>> 
>>>> The following is th log trace I receive from the server: 
>>>> ======================================== 2016-09-05
>>>> 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.a.coyote.http11.Http11InputBuffer      : Received [GET 
>>>> /push?VIN=testrun HTTP/1.1 User-Agent: Freematics Connection:
>>>> keep-alive Host:
>>>> 
>>>> ]
>>> Until a real expert comes along with a better answer let me
>>> just toss this out:  Are the lines in the HTTP request that the
>>> Arduino submits terminated with \r\n (and not just \n)?
>>> Because it looks like the entire request may have been read
>>> when reading the request line.  Then when it goes to read the
>>> headers it gets an EOF.  Not 100% sure of this but it's
>>> possible.
>>> 
>>> 
>>>> 2016-09-05 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.a.c.authenticator.AuthenticatorBase    : Security checking
>>>> request GET /push 2016-09-05 13:32:50.238 DEBUG 13143 ---
>>>> [nio-8080-exec-1] org.apache.catalina.realm.RealmBase      :
>>>> No applicable constraints defined 2016-09-05 13:32:50.238
>>>> DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.a.c.authenticator.AuthenticatorBase    :  Not subject to
>>>> any constraint 2016-09-05 13:32:50.238 DEBUG 13143 ---
>>>> [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   :
>>>> Set encoding to UTF-8 2016-09-05 13:32:50.238 DEBUG 13143 ---
>>>> [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   :
>>>> Decoding query null UTF-8 2016-09-05 13:32:50.238 DEBUG 13143
>>>> --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters
>>>> : Start processing with input [VIN=testrun] 2016-09-05
>>>> 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.s.b.w.f.OrderedRequestContextFilter    : Bound request
>>>> context to thread:
>>>> org.apache.catalina.connector.RequestFacade@75c83bc4 
>>>> 2016-09-05 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.s.web.servlet.DispatcherServlet        : DispatcherServlet
>>>> with name 'dispatcherServlet' processing GET request for
>>>> [/push] 2016-09-05 13:32:50.238 DEBUG 13143 ---
>>>> [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping :
>>>> Looking up handler method for path /push 2016-09-05
>>>> 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler
>>>> method [public void
>>>> de.cyface.obd2.controller.Obd2Controller.push()] 2016-09-05
>>>> 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.s.b.f.s.DefaultListableBeanFactory     : Returning cached
>>>> instance of singleton bean 'obd2Controller' 2016-09-05
>>>> 13:32:50.238 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.s.web.servlet.DispatcherServlet        : Last-Modified
>>>> value for [/push] is: -1 push 2016-09-05 13:32:50.239 DEBUG
>>>> 13143 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet
>>>> : Null ModelAndView returned to DispatcherServlet with name
>>>> 'dispatcherServlet': assuming HandlerAdapter completed
>>>> request handling 2016-09-05 13:32:50.239 DEBUG 13143 ---
>>>> [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        :
>>>> Successfully completed request 2016-09-05 13:32:50.239 DEBUG
>>>> 13143 --- [nio-8080-exec-1] 
>>>> o.s.b.w.f.OrderedRequestContextFilter    : Cleared
>>>> thread-bound request context:
>>>> org.apache.catalina.connector.RequestFacade@75c83bc4 
>>>> 2016-09-05 13:32:50.239 DEBUG 13143 --- [nio-8080-exec-1] 
>>>> o.apache.coyote.http11.Http11Processor   : Socket: 
>>>> [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@2940dec1:o
rg.apache.tomcat.util.net.NioChannel@34a92297:java.nio.channels.SocketCh
annel[connected
>>>>
>>>>
>>>> 
local=/10.42.0.1:8080 remote=/10.42.0.72:46701]], Status in:
>>>> [OPEN_READ], State out: [OPEN] 2016-09-05 13:32:55.280 DEBUG
>>>> 13143 --- [nio-8080-exec-2] 
>>>> o.apache.coyote.http11.Http11Processor   : Error parsing
>>>> HTTP request header
>>>> 
>>>> java.io.EOFException: null at 
>>>> org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuf
fer(NioEndpoint.java:1222)
>>>>
>>>>
>>>> 
~[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEnd
point.java:1163)
>>>>
>>>>
>>>> 
~[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.j
ava:742)
>>>>
>>>>
>>>> 
~[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11I
nputBuffer.java:404)
>>>>
>>>>
>>>> 
~[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.coyote.http11.Http11Processor.service(Http11Processor.ja
va:994)
>>>>
>>>>
>>>> 
~[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorL
ight.java:66)
>>>>
>>>>
>>>> 
[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(Abstra
ctProtocol.java:785)
>>>>
>>>>
>>>> 
[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEnd
point.java:1425)
>>>>
>>>>
>>>> 
[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorB
ase.java:49)
>>>>
>>>>
>>>> 
[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at 
>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecuto
r.java:1142)
>>>>
>>>>
>>>> 
[na:1.8.0_91]
>>>> at 
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecut
or.java:617)
>>>>
>>>>
>>>> 
[na:1.8.0_91]
>>>> at 
>>>> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(Task
Thread.java:61)
>>>>
>>>>
>>>> 
[tomcat-embed-core-8.5.4.jar:8.5.4]
>>>> at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91] 
>>>> =======================================
>>>> 
>>>> Thanks and regards Klemens
>>>> 
>>> 
>>> --------------------------------------------------------------------
- -
>>>
>>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>> 
>> Hi,
>> 
>> Thanks for the answer.
>> 
>> The request is formatted on the Arduino like: "GET
>> /push?VIN=testrun HTTP/1.1\r\nUser-Agent:
>> Freematics\r\nConnection: keep-alive\r\nHost: \r\n"
>> 
>> So yes, all lines are terminated with \r\n
>> 
>> Regards Klemens
> 
> 
> Is an additional CRLF expected?  From RFC 2616:
> 
> generic-message = start-line *(message-header CRLF) CRLF [
> message-body ] start-line      = Request-Line | Status-Line

Yup, a valid HTTP/1.1 request must end with CR LF CR LF.

Klemens, try adding *another * CR LF pair to your request to see if
that improves things.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJXzv+NAAoJEBzwKT+lPKRYsrwP/3fRwVuhgQRBw6uMiEKBYs6c
nTbpNfUkSI6jeVlyLfeCdHCMOg5zcxPq3yeIn6ulpNYhsWaM/nURSq4DuHu7HXSt
Rt8Z7yQArbtKfdQUZsjSp3ZPF3FuUBL9d0/G+y+xgKkCsEvaPH3ib3Z1aUAROnmH
ZVB//hqHPcpvgwgyxMAxl8mA29jsZ3D/cLT6N50nRY1y9v09tRTXMBO+Mkw8cxL7
WWkucd+NzkCF4pf5zY64UEMoNuodexa7Qi96dZLcArH4GuSosFZtxaVBnOdqZ2EF
llWVuSdnW5QxaPtI4vEkr96Z9zSfnptYAlnRBK35uprKdivUo3HitWHInGKX42kA
PmLm+hhVABAHPYZ2XCdevP+VkBlIsfv7mNeNW17jY+FFvM+iVCPxgNIh3z6EXHI0
6hGCCz6SxtHJ6dSruWxzC2NwDxVA1OGpDICeoTir5RylRk/h3ZJpWp/w3+aeHQnN
zn1ENZaFITjRmNwNgbLYZk1VCTALerkf3egR3Y8L6WxRjjzOKsm3H1tIBRF9SGmr
/OHJ3s8cXjhlr7+ojlWb4yBad79vR1CQEe5+uynP5nOLbogBHVIfBW8soVUD2IrX
SP8QZRTnqV1l5IXXtwukzmr8WCeP1pRSU6aszjYY+KCGOIH1ZOH22OwFR1qzVxlV
5kby5r2TSZWg2HIxDjBt
=ylEK
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to