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:org.apache.tomcat.util.net.NioChannel@34a92297:java.nio.channels.SocketChannel[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.fillReadBuffer(NioEndpoint.java:1222)
> ~[tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1163)
> ~[tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:742)
> ~[tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:404)
> ~[tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:994)
> ~[tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> [tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
> [tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
> [tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> [tomcat-embed-core-8.5.4.jar:8.5.4]
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> [na:1.8.0_91]
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> [na:1.8.0_91]
>     at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.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

Reply via email to