我使用Spring的WebSocketConnectionManager来处理WebSocket。有时连接关闭,我必须重新连接。但是我没有找到合适的解决方案。我可以使用WebSocketConnectionManager进行还原(重新连接)会话吗?在我看到的资源中,该连接通过以下代码建立:
@Override
protected void openConnection() {
if (logger.isInfoEnabled()) {
logger.info("Connecting to WebSocket at " + getUri());
}
ListenableFuture<WebSocketSession> future =
this.client.doHandshake(this.webSocketHandler, this.headers, getUri());
future.addCallback(new ListenableFutureCallback<WebSocketSession>() {
@Override
public void onSuccess(@Nullable WebSocketSession result) {
webSocketSession = result;
logger.info("Successfully connected");
}
@Override
public void onFailure(Throwable ex) {
logger.error("Failed to connect", ex);
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我的Spring Boot应用程序启动时,我正在使用此管理器:
WebSocketConnectionManager connectionManager = new WebSocketConnectionManager(
new StandardWebSocketClient(), webSocketHandler, "wss://localhost:8080/ws/");
connectionManager.start();
Run Code Online (Sandbox Code Playgroud)
但是当连接关闭时我该怎么办?我试图从openConnection()复制一段代码,并将其用于直接在webSocketHandler中更新会话,并且它可以工作。但是,这似乎是肮脏的解决方法。
有人知道如何正确执行吗?谢谢。
有人知道如何在Stripe中强制续订(收费)订阅吗?例如,我们有"逾期"订阅,3次尝试在此"过期"期间收费.客户添加新的付款来源(信用卡),并希望立即使用它.但是,"过期"时间表的下一次收费将在几天内完成.我们如何立即拨打费用(创建发票并付款)?任何想法非常感谢!
我在Os X High Sierra上使用带有嵌入式Tomcat服务器和Intellij Idea 2018.2的Spring Boot 2.0.4.RELEASE。
正如教程所说
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html
我在依赖项之后添加了pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
然后我看到
[restartMainMain] osbdaOptionalLiveReloadServer:LiveReload服务器在端口35729上运行
服务器启动时。
但是无论如何,静态源中的更改都无效,我必须按Cmd + F9才能在浏览器中看到它。
我尝试了IntelliJ 15的所有技巧,SpringBoot devtools livereload无法正常工作
例如启用“以编程方式构建项目”或“ compiler.automake.allow.when.app.running”,但没有任何帮助。
我的静态源(angularjs模板和文件)位于
src> main>资源>静态>模板
可能是静态位置错误?
任何想法表示赞赏!