Reputation: 128
Ive spent all day looking for a solution to be able to increase the buffer size of a websocket. So far nothing I have found has worked. At the moment my code is:
@OnOpen
public void open(Session session, EndpointConfig conf) {
session.setMaxBinaryMessageBufferSize(5242880);
System.out.println("Server has been opened with max binary message buffer size of: "+session.getMaxBinaryMessageBufferSize());
}
However this outputs:
Server has been opened with max binary message buffer size of: 65536
Despite the fact I changed it on the line above. I have tried many other solutions and have finally given up and decided to make a post after hours of work.
Thanks for your help! ~lava
Upvotes: 2
Views: 5338
Reputation: 6314
You need to do it with the @OnMessage
annotation, for a binary message it will be (you can verify with the variant that includes session
):
@OnMessage(maxMessageSize = 5242880)
public void onBinary(byte[] message, Session session)
{
System.out.println("max size:" + session.getMaxBinaryMessageBufferSize());
}
Upvotes: 5