Azure / qpid-proton-j-extensions maxframesize将消息大小限制为4KB

问题描述 投票:0回答:1

Azure / qpid-proton-j-extensions如果dsetination缓冲区小于消息流似乎被硬编码为4KB加上一些头信息,那么WebSocketHandlerImpl会抛出异常...从我读过的azure服务总线允许消息到256KB,1MB高级版,加上64KB标头

无论如何我们可以把它提升到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);
java azure service bus
1个回答
0
投票

根据源代码WebSocketHandlerImpl.java#L90如下,我认为你有一个错误,用变量dstBuffer.capacity() >= webSocketFrame.size()理解代码webSocketFrame

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

webSocketFrame变量尚未使用固定大小进行硬编码,这是一个带有自动增长缓冲区的ByteArrayOutputStream对象。但是,dstBuffer变量是一个ByteBuffer对象,具有固定大小的有效载荷和websocket标头,请参考测试代码WebSocketHandlerImplTest.java,如下所示。

// 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
© www.soinside.com 2019 - 2024. All rights reserved.