0

Azure/qpid-proton-j-extensions WebSocketHandlerImpl throws an exception if the dsetination buffer is smaller than the message stream which seems to be hardcoded to 4KB plus some header info... from what i've read azure service bus allows messages up to 256KB, 1MB for premium, plus a 64KB header

is there anyway we can get this up'd to 256KB?

WebSocketHandlerImpl:
 dstBuffer.clear();
            if (dstBuffer.capacity() >= webSocketFrame.size()) {
                dstBuffer.put(webSocketFrame.toByteArray());
            } else {
                throw new OutOfMemoryError("insufficient output buffer size");
            }
        } else {

WebSocketImpl:
  private int maxFrameSize = (4 * 1024) + (16 * WebSocketHeader.MED_HEADER_LENGTH_MASKED);
JoseMPita
  • 3
  • 1

1 Answers1

0

According to the source code WebSocketHandlerImpl.java#L90 as below, I think you have a mistake for understanding the code dstBuffer.capacity() >= webSocketFrame.size() with variable webSocketFrame.

// Auto growing buffer for the WS frame, initialized to minimum size
ByteArrayOutputStream webSocketFrame = new ByteArrayOutputStream(WebSocketHeader.MIN_HEADER_LENGTH_MASKED + dataLength);

The webSocketFrame variable has not been hardcoded with a fixed size, which is a ByteArrayOutputStream object with auto growing buffer. However, the dstBuffer variable is a ByteBuffer object with a fixed size of payload and websocket header, please refer to the test code WebSocketHandlerImplTest.java, such as below.

// public void testWrapBuffer_short_payload() {
// L296
int payloadLength = 100;
int messageLength = payloadLength + WebSocketHeader.MIN_HEADER_LENGTH_MASKED;

// L305
ByteBuffer srcBuffer = ByteBuffer.allocate(payloadLength);
ByteBuffer dstBuffer = ByteBuffer.allocate(messageLength);

// And others functions testWrapBuffer_xxxx_payload
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Hi Peter, so the webSocketFrame is fine thats essentially where the message is, but the ByteBuffer is initialized in the WebSocketImpl constructor as outputBuffer = newWriteableBuffer(maxFrameSize); – JoseMPita Apr 24 '19 at 09:34
  • Hmm so I think you're right, i'm looking in the wrong place, seems WebsocketConnectionHandler in azure-servicebus 2.0.0 also recognizes the limitation?? public int getMaxFrameSize() { // This is the current limitation of https://github.com/Azure/qpid-proton-j-extensions // once, this library enables larger frames - this property can be removed. return AmqpConstants.WEBSOCKET_MAX_FRAME_SIZE; } – JoseMPita Apr 24 '19 at 09:59