【问题标题】:How do I override the websocket.textBufferSize property of an embedded Tomcat with Spring Boot?如何使用 Spring Boot 覆盖嵌入式 Tomcat 的 websocket.textBufferSize 属性?
【发布时间】:2018-10-03 23:43:10
【问题描述】:

在 Tomcat 8.5 的 websocket how-to 中提到了 org.apache.tomcat.websocket.textBufferSize 属性。它说:

文本消息的默认缓冲区大小为 8192 字节。这可以通过将 servlet 上下文初始化参数 org.apache.tomcat.websocket.textBufferSize 设置为所需的字节值来更改 Web 应用程序。

我正在通过 Spring Boot 使用嵌入式 Tomcat,并且需要修改该 init-param。我查看了 Spring Boot 管理的 common application properties 并没有在其中找到该参数。我已将它作为(例如)org.apache.tomcat.websocket.textBufferSize: 40000 放在 application.yaml 中,并从 Tomcat 收到一条消息:The decoded text message was too big for the output buffer and the endpoint does not support partial messages

这些必须是完整的消息,而不是部分消息。

我希望我可以将该属性更改为高于 Tomcat 设置的默认值 (8192)。

【问题讨论】:

    标签: java tomcat spring-boot websocket


    【解决方案1】:

    您可以像 session.setMaxTextMessageBufferSize(20000) 一样在 @OnOpen 处理程序中设置 Session (javax.websocket.Session) 对象的所需大小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-22
      • 2015-10-06
      • 2017-03-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 2019-03-20
      • 2015-03-23
      相关资源
      最近更新 更多