Project

General

Profile

Frequent usage of WebSockets causes java.nio.BufferUnderflowException

Igor Khomenko
Added about 4 years ago

I have a case where we send fast a lot of messages, lets say 1 per second and after some time we get an exception:

2015-03-06 13:37:36.888 [ResultsListener-socketReadThread-0]  SocketThread$ResultsListener.run()  WARNING: Protocol execution exception.
java.util.concurrent.ExecutionException: java.nio.BufferUnderflowException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at tigase.net.SocketThread$ResultsListener.run(SocketThread.java:586)
Caused by: java.nio.BufferUnderflowException
    at java.nio.Buffer.nextGetIndex(Buffer.java:498)
    at java.nio.HeapByteBuffer.getShort(HeapByteBuffer.java:304)
    at tigase.server.websocket.WebSocketXMPPIOService.decodeFrame(WebSocketXMPPIOService.java:387)
    at tigase.server.websocket.WebSocketXMPPIOService.readData(WebSocketXMPPIOService.java:130)
    at tigase.xmpp.XMPPIOService.processSocketData(XMPPIOService.java:617)
    at tigase.net.IOService.call(IOService.java:262)
    at tigase.net.IOService.call(IOService.java:103)
    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:745)

And as a result client can't send more messages after this - just no response from server

We use Tigase 5.2. Any ideas?


Replies (1)

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

In some cases in implementation of WebSocket protocol in Tigase 5.2.x might throw this exception - especially when connection was under used frequently as to input buffer not whole WebSocket header was read and implementation expected that whole header of WebSocket frame was read - this caused issue.

We discovered this during our development work for Tigase XMPP Server 7.0.0 and fixed issue in this release. As I remember we also fixed this in 5.2.3 bugfix release of Tigase XMPP Server.

    (1-1/1)