tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Stöcker <alexander_stoec...@web.de>
Subject Unable to establish WebSocket connection on Tomcat Embed (9.0.24)
Date Mon, 04 Nov 2019 12:59:51 GMT
My code is basically just:

        Tomcat tomcat = new Tomcat();
        tomcat.getConnector();
        tomcat.setPort(8080);

        Context context = tomcat.addContext("/context", new
File(".").getAbsolutePath());

        // servlet
        Tomcat.addServlet(context, "myServlet", new MyServlet());
        context.addServletMappingDecoded("/hello", "myServlet");

        // websocket
        context.addApplicationListener(MyWSContextListener.class.getName());

        // run
        tomcat.start();
        tomcat.getServer().await();


The WsContextListener is adding an Endpoint when contextInitialized()
is called. Setting a Breakpoint shows that the code is actually
executed. The Servlet is working but when I'm trying to connect to the
endpoint ("ws://localhost:8080/context/endpoint") I get a 404. On Fine
debug output I can see, that this exception is thrown, whenever a
connection is requested:

FINE: Error parsing HTTP request header
java.io.EOFException
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1239)
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1139)
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:735)
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:353)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:292)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Thanks for your help & best regards
Alex

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


Mime
View raw message