Project

General

Profile

websocket handshake IndexOutOfBoundsException

Matthew M
Added over 4 years ago

We got a few exceptions in Tigase logs related to web socket session. It does not happens all the time. Do you have any idea what it could be? We are using 5.2.0 final release:

exception processing websocket handshake
java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkBounds(Buffer.java:559)
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:143)
at tigase.server.websocket.WebSocketXMPPIOService.readData(WebSocketXMPPIOService.java:174)
at tigase.xmpp.XMPPIOService.processSocketData(XMPPIOService.java:800)
at tigase.net.IOService.call(IOService.java:257)
at tigase.net.IOService.call(IOService.java:98)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
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:744)

Thanks!


Replies (3)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 4 years ago

As mentioned in one of earlier questions about WebSocket (see https://projects.tigase.org/boards/4/topics/1752?r=1757#message-1757) this is propably due to not whole frame being in buffer when data is processed.

Quote:

??... we will need to add additional checking if we have whole frame header before processing it.??

Added by Matthew M over 4 years ago

Thanks a lot! For this bug

 we will need to add additional checking if we have whole frame header before processing it.

Is there any patch for it in tigase repo? Or it would great if you could post some sample code here on how to fix it?

We would like to put web socket in use but is kind of being blocked by this issue...

Many thanks!

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 4 years ago

I've just rewritten part of handling WebSocket handshake as well as decoding of WebSocket frames. In new version I removed static size of buffer during handshake and improved handling of partial frame in buffer during decoding of frame. Fixed should be part of next SNAPSHOT build.

    (1-3/3)