简体   繁体   English

我们可以再次利用相同的websocket连接吗?

[英]Can we utilize same websocket connection again?

Usecase: 用例:

  1. I have connected to server via Websocket. 我已经通过Websocket连接到服务器。
  2. Some how I got disconnected. 一些我如何断开连接。
  3. Now server have something to deliver using same websocket. 现在服务器可以使用相同的websocket交付一些东西。
  4. after few seconds I connected again.(My question raise here.) 几秒钟后,我再次连接。(我的问题在这里提出。)

When I(Client) connected again. 当我(客户端)再次连接时。 (Is there any way that I can reutilize same websocket connection I was connected earlier? ) Or Every time I have to reconnect using new websocket connection only? (有什么方法可以重用以前连接的相同的Websocket连接?)或每次我只需要使用新的Websocket连接重新连接时?

Answer to your question heavily relies on the implementations. 对您的问题的回答在很大程度上取决于实现。 From what I know, it is possible, but.. 据我所知,这是可能的,但是..

When WebSocket support is implemented on top of Servlet 3.1 API, it might not be possible, because I don't think that servlet implementation is able to reuse upgraded connection. 当在Servlet 3.1 API上实现WebSocket支持时,可能是不可能的,因为我认为Servlet实现无法重用升级后的连接。 Additionally, it also depends on the way how the connection was closed - closing the underlying TCP connection is valid close from WebSocket RFC point of view and then you don't have anything to reuse. 此外,这还取决于关闭连接的方式-从WebSocket RFC角度来看,关闭基础TCP连接是否有效是有效的,那么您就没有任何可重用的内容。

My qualified guess would be (if you are implementing client) - if the connection is left intact after close is detected, you might try to reuse it. 我的合格猜测是(如果正在实施客户端)-如果在检测到关闭后连接保持完整,则可以尝试重用它。 Otherwise you need to open the new one. 否则,您需要打开新的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们如何利用自定义的@Qualifier 方法? - How can we utilize the custom @Qualifier methods? Java Websocket连接检查同一用户是否重新连接 - Java websocket connection check if same user reconnects 无法从JavaScript建立WebSocket连接 - Can not establish a WebSocket connection from JavaScript spring 是否同时支持 Rest 和 Websocket 控制器/连接? - does spring support Rest and Websocket controllers/connection at the same time? 从同一个网络浏览器选项卡禁用多个 websocket 连接 - Disable multiple websocket connection from the same webbrowser tab 在生成新的密码哈希时,如何在应用程序的容器中使用相同的凭据处理程序配置? - How can I utilize the same credential handler configuration for my application's container in generating new password hashes? 我们可以在Spring Cloud Stream应用程序启动程序中使用WebSocket接收器作为WebSocket源吗? - Can we use WebSocket sink, in Spring cloud stream app starters, as WebSocket source? 我无法连接到 Liferay 7.2 中的 websocket“wss”协议 - I can't make a connection to the websocket "wss" protocol in Liferay 7.2 WebSocket连接已建立,但客户端无法接收来自其他人的消息 - WebSocket Connection Established, but Client Can't Receive Messages from Others WebSocket连接在一段时间后无法重新连接 - WebSocket connection can't reconnect after some time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM