[英]SockJS increase pool size
I am using SocketJS and Stomp to send files over a backend api for being process.我正在使用 SocketJS 和 Stomp 通过后端 api 发送文件以进行处理。 My problem is that the upload function get stuck if more than two upload are done at the same time.
我的问题是,如果同时完成两个以上的上传,上传功能就会卡住。
Ex:前任:
(after a minute User 1 complete its upload and the third upload starts) (一分钟后,用户 1 完成上传,第三次上传开始)
The error I can see through the log is the following:我可以通过日志看到的错误如下:
2021-06-28 09:43:34,884 INFO [MessageBroker-1] org.springframework.web.socket.config.WebSocketMessageBrokerStats.lambda$initLoggingTask$0: WebSocketSession[11 current WS(5)-HttpStream(6)-HttpPoll(0), 372 total, 26 closed abnormally (26 connect failure, 0 send limit, 16 transport error)], stompSubProtocol[processed CONNECT(302)-CONNECTED(221)-DISCONNECT(0)], stompBrokerRelay[null], **inboundChannel[pool size = 2, active threads = 2**, queued tasks = 263, completed tasks = 4481], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 607], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 14, completed tasks = 581444]
It seems clear that the pool size is full:显然池大小已满:
inboundChannel[pool size = 2, active threads = 2 inboundChannel[池大小 = 2,活动线程 = 2
but I really cannot find a way to increase the size.但我真的找不到增加尺寸的方法。
This is the code:这是代码:
Client side客户端
ws = new SockJS(host + "/createTender");
stompClient = Stomp.over(ws);
Server side configuration服务器端配置
@EnableWebSocketMessageBroker
public class WebSocketBrokerConfig extends AbstractWebSocketMessageBrokerConfigurer {
...
...
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
registration.setMessageSizeLimit(100240 * 10240);
registration.setSendBufferSizeLimit(100240 * 10240);
registration.setSendTimeLimit(20000);
}
I've already tried with changing the configureWebSocketTransport parameters but it did not work.我已经尝试过更改 configureWebSocketTransport 参数,但没有奏效。 How can I increase the pool size of the socket?
如何增加套接字的池大小?
The inbound channel into the WebSocket can be overwritten by using this method:可以使用以下方法覆盖进入 WebSocket 的入站通道:
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.taskExecutor().corePoolSize(4);
registration.taskExecutor().maxPoolSize(4)
}
The official documentation suggests to have a pool size = number of cores. 官方文档建议使用池大小 = 内核数。 For sure, since the maxPoolSize is reached then requests are handled through an internal queue.
当然,由于达到了 maxPoolSize,因此请求将通过内部队列进行处理。 So, given this configuration I can process concurrently 4 requests.
因此,鉴于此配置,我可以同时处理 4 个请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.