Pregunta

Usecase:

  1. I have connected to server via Websocket.
  2. Some how I got disconnected.
  3. Now server have something to deliver using same 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?

¿Fue útil?

Solución

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. 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.

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top