Hi Mark,
> -----Original Message-----
> From: Mark Thomas [mailto:[email protected]]
> Sent: Saturday, October 5, 2013 9:46 PM
> To: Tomcat Developers List
> Subject: Re: 8.0.x / 7.0.x progress
>
> On 05/10/2013 20:42, Konstantin Preißer wrote:
>
> > One question, would it be possible to make Session.getAsyncRemote()
> > throw some RuntimeException when using the BIO connector, instead of
> > silently using blocking writes?
>
> No. WebSocket is written on top of the Servlet 3.1 API. It has no access
> to Tomcat internals.
>
> > If getAsyncRemote() instead threw an exception saying that you need
> > NIO or APR for this method, I think this might save someone such a
> > surprise (but I must admit that I do not know much about Servlet
> > 3.1's NIO features and how there the situation is with BIO
> > connector).
> >
> > What do you think?
>
> I think breaking apps in this way is worse than using blocking IO.
OK, thank you for your explanation. (Personally I'm not convinced of this yet -
I would think getting exceptions on getAsyncRemote() is more safe then silently
risk a DoS (but I probably do not have as much knowledge and experience to
fully understand the consequences) - but as you say Websocket has no access to
Tomcat's internals so it doesn't matter either.)
When I was writing the bug report for the websocket problems with NIO and APR
connector [1], I updated trunk to the current revision, and after I started
Tomcat with NIO and opened the snakes example, I got corrupt data on Firefox
and exceptions on Tomcat like the following:
06-Oct-2013 03:44:34.083 SEVERE [http-nio-8080-exec-2]
org.apache.tomcat.websocket.pojo.PojoEndpointBase.onError Failed to call
onError method of POJO end point for POJO of type
[websocket.snake.SnakeAnnotation]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.onError(PojoEndpointBase.java:131)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.handleOnOpenError(PojoEndpointBase.java:91)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.doOnOpen(PojoEndpointBase.java:71)
at
org.apache.tomcat.websocket.pojo.PojoEndpointServer.onOpen(PojoEndpointServer.java:70)
at
org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:129)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1620)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1578)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.nio.charset.CoderMalfunctionError:
java.nio.BufferOverflowException
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:565)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase$TextMessageSendHandler.write(WsRemoteEndpointImplBase.java:620)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:197)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:154)
at
org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)
at websocket.snake.Snake.sendMessage(Snake.java:66)
at websocket.snake.SnakeTimer.broadcast(SnakeTimer.java:83)
at websocket.snake.SnakeAnnotation.onOpen(SnakeAnnotation.java:90)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.doOnOpen(PojoEndpointBase.java:58)
... 9 more
Caused by: java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:513)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
at
org.apache.tomcat.util.buf.Utf8Encoder.encodeNotHasArray(Utf8Encoder.java:169)
at
org.apache.tomcat.util.buf.Utf8Encoder.encodeLoop(Utf8Encoder.java:40)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:561)
... 20 more
06-Oct-2013 03:44:34.486 SEVERE [http-nio-8080-exec-2]
org.apache.tomcat.websocket.pojo.PojoEndpointBase.onError Failed to call
onError method of POJO end point for POJO of type
[websocket.snake.SnakeAnnotation]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.onError(PojoEndpointBase.java:131)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.handleOnOpenError(PojoEndpointBase.java:91)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.doOnOpen(PojoEndpointBase.java:71)
at
org.apache.tomcat.websocket.pojo.PojoEndpointServer.onOpen(PojoEndpointServer.java:70)
at
org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:129)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1620)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1578)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:185)
at
org.apache.coyote.http11.upgrade.NioServletOutputStream.doWriteInternal(NioServletOutputStream.java:75)
at
org.apache.coyote.http11.upgrade.NioServletOutputStream.doWrite(NioServletOutputStream.java:60)
at
org.apache.coyote.http11.upgrade.AbstractServletOutputStream.writeInternal(AbstractServletOutputStream.java:116)
at
org.apache.coyote.http11.upgrade.AbstractServletOutputStream.write(AbstractServletOutputStream.java:83)
at
org.apache.tomcat.websocket.server.WsRemoteEndpointImplServer.onWritePossible(WsRemoteEndpointImplServer.java:84)
at
org.apache.tomcat.websocket.server.WsRemoteEndpointImplServer.doWrite(WsRemoteEndpointImplServer.java:71)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.writeMessagePart(WsRemoteEndpointImplBase.java:358)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessage(WsRemoteEndpointImplBase.java:259)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase$TextMessageSendHandler.write(WsRemoteEndpointImplBase.java:626)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:197)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:154)
at
org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)
at websocket.snake.Snake.sendMessage(Snake.java:66)
at websocket.snake.SnakeTimer.broadcast(SnakeTimer.java:83)
at websocket.snake.SnakeAnnotation.onOpen(SnakeAnnotation.java:90)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.tomcat.websocket.pojo.PojoEndpointBase.doOnOpen(PojoEndpointBase.java:58)
... 9 more
These errors seem to be introduced with r1529537 [2], as I get these errors
with that revision, but with the previous one (r1529536) it works fine.
[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=55633
[2] http://svn.apache.org/viewvc?view=revision&revision=1529537
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]