wildfly - Wildfly 挂起导致 undertow websocket 连接失败
问题描述
我有一个简单的@Startup 服务,其中包含一系列 websocket 连接创建的 @PostConstruct 方法:
public void connect(String uri, int timeOut) throws Exception {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
ClientEndpointConfig config = Builder.create().build();
config.getUserProperties().put("io.undertow.websocket.CONNECT_TIMEOUT", timeOut);
container.connectToServer(this.endpoint, config, new URI(uri));
}
在某些时候,connectToServer 调用因ClosedChannelException
. 就代码逻辑而言,原因非常简单,但我不知道如何解决它: Wildfly 挂起导致ServerWebSocketContainer::pause
被调用
public synchronized void pause(PauseListener listener) {
closed = true;
...
并且以ServerWebSocketContainer::connectToServer
我能想象的最糟糕的方式处理这种行为:)
public Session connectToServer(final Endpoint endpointInstance, final ClientEndpointConfig config, final URI path) throws DeploymentException, IOException {
if(closed) {
throw new ClosedChannelException();
}
...
- 如何等待undertow满载?
- 如何在 ServletContextListener 中注入 @Ejb 类来移动 contextInitialized 中的任务?
- 或者也许利用球衣ApplicationEventListener?
在延迟 10-15 秒的新线程中执行没有意义 - 可能ContainerProvider.getWebSocketContainer()
会导致加载扩展加载,然后是UndertowDeploymentInfoService::suspend
解决方案
推荐阅读
- html - 我的导航正在做一些我没有告诉它做的事情?
- amazon-web-services - Boto3 调用 Lambda 函数在开发中有效,但在生产中无效?
- django - 如何在 Django 模型中使用 get 函数作为字段?
- apache-nifi - 在 NIFI 中设置默认处理器属性
- elasticsearch - 从以前的 elasticsearch 版本 (5.4 -> 5.6) 中清理分片
- html - 引导顺序会根据显示为 1 列还是 2 列而变化
- r - 当我“文件/打开项目...”时更改 RStudio 打开的默认目录
- java - 在mysql中将displayimage保存为blob到jsp中的视图
- r - 选择数据框中大部分非零的行
- intellij-idea - 实用程序类的内部对象?