我使用了Spring实现的sockjs WebSocket服务器,但无法传输超过8KB的消息,以下是错误信息:
2014-02-12 19:36:29,990 - org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession - DEBUG - SockJS session id=35n41xel was closed, CloseStatus [code=1009, reason=The decoded text message was too big for the output buffer and the endpoint does not support partial messages]
你有什么想法可以增加缓冲区大小吗?
我使用了以下的工厂,因为Spring SockJS利用Tomcat容器(应用程序部署在Tomcat中,我也进行了调试以确认它确实使用Tomcat库)
@Bean
public WebSocketContainerFactoryBean createWebSocketContainer() {
WebSocketContainerFactoryBean container = new WebSocketContainerFactoryBean();
container.setMaxTextMessageBufferSize(16384);
container.setMaxBinaryMessageBufferSize(8192);
return container;
}
然后我的URL映射如下:
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(coBrowseSockJsCustomerHandler(), "/sockjs/cobrowse/customer/").withSockJS();}
我需要在哪里设置这个bean才能使用sockjs?sockjs如何知道它必须使用这个工厂?